prasadbabu has asked for the wisdom of the Perl Monks concerning the following question:
Monks, Today my colleague asked me to just replace the entities ~~~ with ~~~ in a small file. Both side of the entities, alphabets or digits or underscore ll be there. So i just wrote a small script but i found strange behaviour.
So i tried with small string sample and found the same answer as shown below:
First tested: ------------- $str = 'abac 123 afa123f'; $str =~ s|\B123\B|***|g; print $str; output i got as i expected: --------------------------- abac 123 afa***f Second tested: -------------- $str = 'abac ~~~ afa~~~ +;f'; $str =~ s|\B\&\#x0007E\;\&\#x0007E\;\&\#x0007E\;\B|~~~|g; print $str; output i got: ------------- abac ~~~ afa~~~f expected output: ---------------- abac ~~~ afa~~~f
For clarification i went through the documentation as well, it says what i expected. Why this strange behaviour. Where am i going wrong?
Prasad
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Word boundary '\B' - Question
by Sidhekin (Priest) on Aug 21, 2006 at 15:29 UTC | |
by prasadbabu (Prior) on Aug 21, 2006 at 15:46 UTC | |
|
Re: Word boundary '\B' - Question
by ikegami (Patriarch) on Aug 21, 2006 at 16:16 UTC | |
by ysth (Canon) on Aug 21, 2006 at 21:32 UTC |