Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Pattern Match n00b

by skirnir (Monk)
on Mar 14, 2008 at 20:59 UTC ( [id://674293]=note: print w/replies, xml ) Need Help??


in reply to Pattern Match n00b

No, to make the .+ part non-greedy you'd have to place the '?' directly after the "+":

@{$pets} = $1 if $pet_list =~ /$some_variable\:(.+?);?/;

But as the ';' is optional, the non-greedy match would stop matching after the first non-newline character. In your example you would get "b" in $1. It's best not to use "." if you don't really mean "any non-newline character". In your case I think [^;] would be the right thing to use, given that I understood properly what you want to do.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-03-29 02:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found