Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

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 about the Monastery: (10)
As of 2018-06-19 07:59 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (111 votes). Check out past polls.