"Maybe you had a specific string in mind, but I don't see how this relates to the OP. He would not use Chi_2 in the regex pattern.
I did have a very similar string in mind.In a world where an identifier matches /^\w+\z/, you might do something like"
($_ = '\\Chi_2+3') =~ s/\\Chi\b/$chi/g; # Won't replace
I understand my update isn't contributing to the OP's original question. I'm not trying to distract from his post or the thread, simply attempting to correct what I said regarding the underscore having no effect on the RegEx's success (again the one I had in mind).
In my original reply I was referring to matching 'Chi' within 'Chi_2' using \b. I previously said that I didn't think the underscore would be a problem. However after some help in the CB from erix and Tanktalus it was shown that an underscore would interfere with this particular match:
say (("Chi_2" =~ /\bChi\b/) ? "match" : "no match");
returns: "no match"
* Thanks again to Tantalus for this control structure.
Again, apologies for any confusion caused.
In reply to Re^3: Defining Characters in Word Boundary?
by luis.roca
in thread Defining Characters in Word Boundary?
by iaw4
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |