Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: regex question

by broomduster (Priest)
on Sep 01, 2008 at 07:13 UTC ( [id://708124]=note: print w/replies, xml ) Need Help??


in reply to regex question

The non-greedy *? is perfectly happy to eat up nothing unless you tell it how far to go. So either use the greedy version for the second capture or anchor with, say, $. Try either of these:

print "$1 $2\n" if($str=~/(.*?)\*(.*)/);

print "$1 $2\n" if($str=~/(.*?)\*(.*?)$/);
Note that both of them produce:
Test .Value
Elimination of that . left as an exercise. ;-)

Replies are listed 'Best First'.
Re^2: regex question
by Alien (Monk) on Sep 01, 2008 at 07:45 UTC
    Thanks for your replies ! I am grateful !

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-25 23:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found