[EMAIL PROTECTED] (Denham Eva) wrote in 
news:[EMAIL PROTECTED]:

> Hello Gurus,
> In a script I have a piece of code as such:-
> ************* snip**************
> my $filedate =~ s/(\d+)//g;
> ************* snip end *******
> The data I am parsing looks as such :-
> ********** DATA ************
> 
> C:/directory/MSISExport_20040814.csv
> 
> C:/directory/MSISExport_20040813.csv
> 
> .
> 
> C:/directory/MSISExport_20030501.csv
> 
> ********** DATA end *********
> Now I am actually trying to dump everything except the date or numerals
> as such :- 20040814
> 
> Can someone help me with that regex? I am having a frustrating time of
> it!
> 
> Much appreciated
> 
> Denham

Denham,

If you have the filename in a scalar called $filename then the code to
place the date into a scalar called $filedate would be:

($filedate) = $filename =~ m|MSISExport_([0-9]+)\.csv|;

This places the captured value in ([0-9]+) into $filedate.  This doesn't 
catch an instance where the filename is malformed and that date doesn't 
exist there.

Hope this helps,

Bill

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to