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

Re: why my reg ex matches greedy?

by McA (Priest)
on Jun 25, 2012 at 20:44 UTC ( [id://978267]=note: print w/replies, xml ) Need Help??


in reply to why my reg ex matches greedy?

Hi,
probably that is what you want:
use strict; use warnings; my $str = '6AG3_608_FGG_20100124_20120923418_20126254447_201262512026. +txt'; $str =~ s/_\d{11,}//g; print $str, "\n";

Replies are listed 'Best First'.
Re^2: why my reg ex matches greedy?
by Anonymous Monk on Jun 25, 2012 at 21:02 UTC
    hi McA, thanks. yes that is what eventually i would need. but i would like to understand the reg ex to extract the pattern.
      Ok ok ok,
      then take this:
      use strict; use warnings; my $str = '6AG3_608_FGG_20100124_20120923418_20126254447_201262512026. +txt'; $str =~ m/(.*?)(_\d{11,}?.*)(\.\w+)/; print $1, "\n"; print $2, "\n"; print $3, "\n";

Log In?
Username:
Password:

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

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

    No recent polls found