develooper Front page | perl.fwp | Postings from March 2002

Re: TPR1 post-mortem

Thread Previous | Thread Next
From:
Honza Pazdziora
Date:
March 8, 2002 06:27
Subject:
Re: TPR1 post-mortem
Message ID:
20020308152659.J5008@anxur.fi.muni.cz
On Fri, Mar 08, 2002 at 03:16:10PM +0100, Marcelo E. Magallon wrote:
> 
>  A question of my own: why doesn't
> 
>     s/\B.\B/$&$&/g
> 
>  work as I expect, namely abcd -> abbccd.  I really can't figure it out
>  by reading the docs.

Because after matching the b and the non-boundaries around it, the
non-boundary between b and c already matched. So the next match for 
non-boundary will match between c and d, and since there is no \B
after d, you'll get abbcd.

You can try to rewrite the regexp as

	s/_(.)_/$+$+/g;

and match

	a_b_c_d

Here, it should be obvious that after matching _b_, your next chance
with _ is between c and d, not between b and c.

Yours,

-- 
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
      ... all of these signs saying sorry but we're closed ...
------------------------------------------------------------------------

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About