Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Skipping special tags in regexes

by dragonchild (Archbishop)
on Dec 04, 2003 at 16:01 UTC ( [id://312230]=note: print w/replies, xml ) Need Help??


in reply to Skipping special tags in regexes

Build dynamic regexes. Maybe something like:
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://312230]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-19 01:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found