my $regex = 's/(\w+)\s+tacos/$1 yummy tacos/g'; $regex =~ s/(\\s\+)(\w)/$1(<\\w\\w>)$2/g; # Handle first part of + substitution my $match = $2; $regex =~ s/ $match/\$2$match/g; # Handle second part o +f substitution eval "$regex";
That would handle the transform from the first to the second. Ideally, you would re-evaluate your regexes and build them using some regex builder. The builder would handle the optional tags and making sure they stayed in after the substitutions.
------
We are the carpenters and bricklayers of the Information Age.
Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.
In reply to Re: Skipping special tags in regexes
by dragonchild
in thread Skipping special tags in regexes
by fletcher_the_dog
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |