Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Regular Expression Pieces

by kelan (Deacon)
on May 07, 2003 at 22:21 UTC ( #256400=note: print w/replies, xml ) Need Help??


in reply to Regular Expression Pieces

Because you only have one pair of parentheses, you'll only get $1 defined. A way that you can catch all your matches would be something like this:

my @matches = ($a =~ m/(\[\[.*?\]\])/g);
Then the array @matches will contain all of the matches and you can step through them if you want by using indices to access @matches. Please note to use the /g modifier at the end of the regex to find every possible match.

kelan


Perl6 Grammar Student

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2022-12-09 03:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?