Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

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.


Comment on Re^2: Regex problem - (non)greedy?
Select or Download Code
Re^3: Regex problem - (non)greedy?
by hdb (Prior) 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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2014-10-02 17:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (66 votes), past polls