Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^2: Regex problem - (non)greedy?

by ikegami (Pope)
on Nov 14, 2013 at 14:31 UTC ( #1062594=note: print w/replies, xml ) Need Help??

in reply to Re: Regex problem - (non)greedy?
in thread Regex problem - (non)greedy?

I expect that doesn't give the intended results for any of the following:

"cdghi" "cd ghi ghi"

Furthermore, that pattern won't help if we wants to go on to handle either of the following:

"cd XXX ghi cd YYY ghi" "cd XXX cd YYY ghi ZZZ ghi"

By the way, you really want to add a leading ^ to that to speed things up greatly when the pattern doesn't match.

Replies are listed 'Best First'.
Re^3: Regex problem - (non)greedy?
by hdb (Monsignor) on Nov 14, 2013 at 14:34 UTC

    I am not sure what the expected results are, but the actual results are:

    cdghi: (no match) cd ghi ghi: ghi cd abc ghi cd def ghi: def
      I expect he'd want "" for the first and "" for the second. As for the third, see my update.

        The first one does not match as the OP contains two spaces at least between 'cd' and 'ghi'.

        Also what would he expect for 'cd cd ghi'?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1062594]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2018-01-24 09:34 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (256 votes). Check out past polls.