Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: extracting numbers from a string

by modred (Pilgrim)
on Feb 07, 2001 at 18:22 UTC ( #56956=note: print w/replies, xml ) Need Help??


in reply to extracting numbers from a string

If they are all in fixed positions you can use substr repeatedly to extract the values or you can use a regular expression and assign from the $1-$9 variable.

perldoc -f substr perldoc perlre

the regular expression code would look something like

$filename='XX-ZZ-YYYYMMDDHH' $filename =~ /^(\d{2})-(\d{2})-(\d{4})(\d{2})(\d{2})(\d{2})$/; # $1 is XX, $2 is ZZ, and so on

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2023-06-10 04:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you go to conferences?






    Results (36 votes). Check out past polls.

    Notices?