P is for Practical | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Not simple dinky ones, but perhaps regexes that got you out of a bind, or were quite sneaky at what they did, ...
A couple of times recently I've used a "nested" regexp to pull off a bit of tricky substition. The "outer" regexp serves as a filter, and the "inner" regex, fired via /e, does a more targetted subsitution (or no substitution at all). In the code below, the challenge was to turn words like "cowsCanFly" into "cows-can-fly". When I first posted this fragment (in this node), there was some concern that the regex engine wasn't reentrant, and that I'd just gotten lucky. Perhaps, though I've done this a few times with 5.6.0 or later, and haven't run into any problems. japhy, since you're now a regex UberLord, perhaps you can vet this approach for reentrancy issues.
In reply to Re: Regular Expressions: Call for Examples
by dws
|
|