|
Cody,
This is not entirely correct...
$string =~
s\(<b>|</b>)\\;
In this situation, /(string1|string2)/
perl looks for a match of either occurence of "string1" and "string2" per
line. If "string1" is found, then perl will never search for "string2" on
the same line. So when you run it only the first <b> tag will be removed
and never the second</b>. In order to fix it a "g" would need to be added
to the last "\" to tell perl not to stop searching after the first match is
found. So...
$string =~
s\(<b>|</b>)\\g;
would work.
However, alternation in regex is resource expensive
and should be avoided if at all possible in complex
operations.
man perlre is great for a quick
reference ;)
--Brian
|
- [luau] Perl String Question Matthew John Darnell
- Re: [luau] Perl String Question Brian McSheehy
- RE: [luau] Perl String Question Taylor Cody L. Contr 502 AOS/PETS
- Re: [luau] Perl String Question Brian McSheehy
