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

Re: Retrieving Regex matched Group name

by frozenwithjoy (Priest)
on Feb 18, 2013 at 22:51 UTC ( #1019408=note: print w/replies, xml ) Need Help??


in reply to Retrieving Regex matched Group name

Without knowing what you are trying to match, I'm just guessing, but my guess is that you want your regex to be something like this:
#!/usr/bin/env perl use strict; use warnings; use feature 'say'; my $string = "<Word>Cat<Digit>1 blah blab blah <Word>Dog<Digit>0"; while ( $string =~ m/<Word>(\w+)<Digit>(\d+)/g ) { say "Matched Word: $1"; say "Matched Digit: $2"; } __END__ Matched Word: Cat Matched Digit: 1 Matched Word: Dog Matched Digit: 0

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1019408]
help
Chatterbox?
[ambrus]: My boss wants to generate output data that is impossible to compute from the inputs we have. And I'm trying to convince him that he shouldn't do that.

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2017-12-12 12:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (332 votes). Check out past polls.

    Notices?