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

Re: Perl Regex

by swl (Parson)
on Nov 17, 2019 at 05:30 UTC ( [id://11108810]=note: print w/replies, xml ) Need Help??


in reply to Perl Regex

Edited about 30 secs after posting - the regex does not work.

Your regex is not delimited. Using the explicit match (m//) notation might help clarify things.

It also needs the g modifier to match all cases.

my $str = 'Link:1625 housing Link:2004'; my @matches = ( $str =~ m/(?:link:) [^\s\|]+/g );

See perlretut for more examples.

(I have not tested that the regex works, though).

Replies are listed 'Best First'.
Re^2: Perl Regex
by swl (Parson) on Nov 17, 2019 at 05:38 UTC

    Try this for the regex. It works with the test data provided.

    my @matches = ( $str =~ m/\|?Link:([\s0-9-]+)/g );

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-04-19 04:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found