I needed to replace all &
with #
, inside and only inside the <faultstring> ... </faultstring>
tag. Additionally, the &
in &
should not be changed. Sample input:
123&&<faultcode>IBM.Error<faultstring>special character & and one converted &</faultstring></faultcode>&&123
Expected output:
123&&<faultcode>IBM.Error<faultstring>special character # and one converted &</faultstring></faultcode>&&123
The following one works with the boundary but also replaces the &
with #amp;
sed -e :1 -e 's@\(<faultstring>.*\)&\(.*</faultstring>\)@\1#\2@;t1'
Also, I'm replacing those patterns inplace with a file.
PS: I created a new question to avoid confusion on my previous thread. If you guys found that this can be merged on the previous thread please do so. I'm just hoping that new thread will attract people to answer quick, and minimize confusion.
&
is used in other HTML characters, like<
,>
,α
,β
, etc?