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.....
foreach (keys %hashstore){
$doc=~s!\b($_)\b!$1/$hashstore{$_}!ig;
}
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"
It seems to detect "/" as a word boundary. Has anyone encountered this or know of a fix around it? Many thanks! Amy