Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: storing string matched by regular expression

by jsegal (Friar)
on Jun 27, 2002 at 14:36 UTC ( [id://177718]=note: print w/replies, xml ) Need Help??


in reply to storing string matched by regular expression

You need to have the expression evaluated in "list context" to get it to return what you are interested in, and you need capturing parentheses inside the pattern to show what you want to collect (in this case, I think it is your entire pattern).
i.e.
($thisresult) = ($teststring =~ /([aft][edt].[ftg]...v{2,3})/g); if ($thisresult) { if (!$lastresult) { print "Expression found\n"; } } $lastresult = $thisresult;
(Note the parentheses around $thisresult and in the pattern). If the match fails, $thisresult would be set to undef.
See "perldoc perlop" the (section on "m") and "perldoc perlre" for more details

--JAS

Log In?
Username:
Password:

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

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

    No recent polls found