I have a file containing directory entries in the following format:
<item><ln></ln><fn>Some person</fn><ct>07123456789</ct><sd>37</sd><rt>1</rt><bw>1</bw></item>
I would like to use sed to search for any where <ct> is an 11 digit number and where <bw>1</bw>. I would like to change the line above like so:
<item><ln></ln><fn>Some person</fn><ct>07123456789</ct><sd>37</sd><rt>1</rt><bw>0</bw></item>
(if it isn't obvious I have changed <bw>= 0)
I have tried the following in sed but it does not match:
sed -E 's/(.+<ct>\d{11}.+<bw>)1(<\/bw><\/item>)/\10\2/g' test-directory.xml
What am I doing wrong?