in reply to Re^2: Defining Characters in Word Boundary?
in thread Defining Characters in Word Boundary?
"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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Defining Characters in Word Boundary?
by ikegami (Patriarch) on Jan 21, 2011 at 07:12 UTC |