Keep It Simple, Stupid | |
PerlMonks |
Getting around "/" as a word boundaryby sherab (Scribe) |
on Aug 12, 2010 at 03:42 UTC ( [id://854567]=perlquestion: print w/replies, xml ) | Need Help?? |
sherab has asked for the wisdom of the Perl Monks concerning the following question:
Hi everyone, I am running into a strange regex issue.... I have a document where I am doing a replace... as an example I want to replace "DEXX" with "DEXX/AREX" and then with the next substitution replace... "AREX" with "AREX/CUBE"
DEXX and AREX are stored in a hash like so.... "DEXX" => "AREX", "AREX" => "CUBE" The regex I have is this.....
What's happening is that "DEXX" is being replaced with "DEXX/AREX" ok but when "DEXX/AREX" is encountered the regex is replacing "DEXX/AREX" with "DEXX/AREX/CUBE" when it should only be replacing "AREX" when it finds it as a standalone word not as part of another combination like "DEXX/AREX" I thought that a negative lookback might work . i.e.....
No luck though It seems to detect "/" as a word boundary. Has anyone encountered this or know of a fix around it? Many thanks!
Back to
Seekers of Perl Wisdom
|
|