|
|
| Come for the quick hacks, stay for the epiphanies. | |
| PerlMonks |
Skipping special tags in regexesby fletcher_the_dog (Friar) |
| on Dec 04, 2003 at 10:42 UTC ( [id://312223]=perlquestion: print w/replies, xml ) | Need Help?? |
This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.fletcher_the_dog has asked for the wisdom of the Perl Monks concerning the following question:
Hi All,
I have files that have some special markers in them something like this: <5b>I <5c>like <5d>tacos I was wondering if there was anyway possible to make the regex engine ignore these tags without deleting them? For example, if I had a regex like this: I would want it to change the above phrase to: <5b>I <5c>like yummy <5d>tacos I realize I could change the regex to: but my script requires quite a few complicated regexes substitutions and having optional "(<\w\w>)?"s everywhere will make the regexes very ugly and make it hard to keep track of which capturing parenthesis are catching what. I was wondering if there was a way to make the regex engine see the a string something like this where it would do its matching just against the first element in each sub array: Another possibilty I have considered and tried was erasing all the tags and then after I was done with all the substitutions doing a diff and trying to reconstruct where the tags should go. This actually works but was way too slow.
Back to
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||