mikeysmailbox1
asked on
Perl replace & in xml data
Hi
I need to replace and & but if there is a & or " do not replace the &
Not sure how to do this.
Thanks
Mike
I need to replace and & but if there is a & or " do not replace the &
Not sure how to do this.
Thanks
Mike
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Two people submitted slightly different solutions and the OP never responded.
What are you replacing it with, the pattern match searches for " & "
You have to account for ..
Please post an example of data sample.
&
If solving before and after is important enclosing \s+ in percentages will assign it when match to $1 and $2
s/(\s+)\&(\s+)/$1replaceme
The first s/ tells this is a find/replace
The ending /g tells it find replace all occurances. Without this, the find/replace will only perform one replacement per line.