Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^4: XML data extraction

by snehit.ar (Beadle)
on Oct 12, 2017 at 09:11 UTC ( [id://1201199]=note: print w/replies, xml ) Need Help??


in reply to Re^3: XML data extraction
in thread XML data extraction

Am able to get the correct date pattern .Thanks.
For regex there will be mostly two sets of parens in single string and always want to pick the values from last set of parens i.e :100
my $name = "greenfield (Glossary) (100)"; my $appID; foreach ( $name =~ /\((.*?)\)/ ) { $appID = $1; } print $appID;

above code gives me output : Glossary

Replies are listed 'Best First'.
Re^5: XML data extraction
by hippo (Bishop) on Oct 12, 2017 at 10:34 UTC
    #!/usr/bin/env perl use strict; use warnings; use Test::More tests => 1; my $name = "greenfield (Glossary) (100)"; my $want = '100'; $name =~ /([^(]+)\)$/; is ($1, $want, "Matched");

    If you want what's at the end, anchor it to the end.

Re^5: XML data extraction
by haukex (Archbishop) on Oct 12, 2017 at 10:35 UTC

Log In?
Username:
Password:

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

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

    No recent polls found