K
Krebul
Hi,
I'm trying to write a regular expression to escape the < charactar
within an XML file. I only want to escape the character when its the
value of a node. Ex:
"<xmlnode>one < two</xmlnode>"
I want to convert that to:
"<xmlnode>one < two</xmlnode>"
The logic I decided to use was to simply escape any < character,
followed by followed by another < character, without a > character in
between.
I cannot get my regexp to work, but the closest I've come was:
$str =~ s/<.*?(?!>)</\<$&</g;
Please advise what I'm doing wrong.
Thanks
-Krebul
I'm trying to write a regular expression to escape the < charactar
within an XML file. I only want to escape the character when its the
value of a node. Ex:
"<xmlnode>one < two</xmlnode>"
I want to convert that to:
"<xmlnode>one < two</xmlnode>"
The logic I decided to use was to simply escape any < character,
followed by followed by another < character, without a > character in
between.
I cannot get my regexp to work, but the closest I've come was:
$str =~ s/<.*?(?!>)</\<$&</g;
Please advise what I'm doing wrong.
Thanks
-Krebul