Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Re: special regexp

by alfie (Pilgrim)
on Mar 26, 2001 at 12:05 UTC ( #67131=note: print w/replies, xml ) Need Help??


in reply to Re: special regexp
in thread special regexp

Uhm, wasn't it you last time that told me about Death to Dot Star! last time? ;-)
I had [^x]*? where you are now using .*? - so why is .*? working here but [^x]*? not? *totallypuzzled*
--
Alfie

Replies are listed 'Best First'.
Re: Re: Re: special regexp
by danger (Priest) on Mar 26, 2001 at 12:30 UTC

    Yours is failing because you've anchored the match to where the previous one left off (with \G) and are also preventing moving across any 'x' characters that don't fit the x(.)(?=x) pattern by using the negative character class. The \G.*?x may traverse over an 'x' if the remainder of the expression fails.

    A simpler solution if you do not want to allow a "matched" 'x' to also count as a boundary 'x' is just:

    $_ = 'xaxbxcxdexfxxxx'; print $1 while /x(.)(?=x)/g; # abcfx

    If you do want to count 'matched' 'x' chars as potential boundary chars as well -- ie, 'xxxx' would produce 'xx' because there are two 'x' characters that have an 'x' on either side -- then:

    $_ = 'xaxbxcxdexfxxxx'; print $1 while /(?<=x)(.)(?=x)/g; # abcfxx

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://67131]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2022-05-18 02:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (68 votes). Check out past polls.

    Notices?