Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: look-behind regexby flocto (Pilgrim) |
on Jul 24, 2002 at 10:22 UTC ( [id://184753]=note: print w/replies, xml ) | Need Help?? |
With your matching regex, you match foo and bar in a rather unelegant way. This is only needed, if you have to assure that toto and foo and in this order. This is unneccessary if
In either one of this two cases, you can just use the following, which should be a lot faster (it propably doesn't make a difference with such short strings, but imagine the backtracking you get when trying to have this regex match a 1000 character long string..):
Once again: If you have only short strings like in your example you can happily live with your solution, if you have to ensure this order you propably have to. It's just unneccessary to match something that you don't need.. Doing all this in just one regex may be possible, but that should rather be used to write Obfuscated Code. Regards,
In Section
Seekers of Perl Wisdom
|
|