in reply to Search and replace again
When dealing with XML, it's generally easier to use pre-rolled solutions like XML::Simple or XML::Twig; however, you can accomplish your goal with character classes - note this assumes that > does not occur in string context - I don't remember what characters are valid in attribute strings:
my $string = '<image attrib="one" attrib2="two" scope="local"/>'; $string =~ s/(<image\s[^>]*?)scope="local"/$1/g; print "$string\n"; __END__ <image attrib="one" attrib2="two" />
See perlretut for more info on character classes.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Search and replace again
by ikegami (Patriarch) on Apr 19, 2010 at 21:52 UTC |