Re: RegExp help..
| From: | David Robley | Date: | Mon, 12 Mar 2001 01:53:29 +0000 |
| Subject: | Re: RegExp help.. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-43425@lists.php.net to get a copy of this message | ||
On Mon, 12 Mar 2001 12:10, John Vanderbeck wrote:
> I really wish I could figure these darn things out :) I have a task I
> need to do, and i'm certain I could do this easily with a regexp..
>
> I have a file name in the format MMDDYY-*.txt...I need to parse it to
> determine if the month and year matches a specified month and year.
> Day is irrelevant
>
> Can any of your regexp wizards help me?
A non-regexp solution that comes to mind is to use substr() to extract
the bits you want from the filename, assuming the filenames to be always
as your example. So:
$month = substr($filename,0,2);
$year = substr($filename,4,2);
Then you have the string values for month and year in the respective
variables.
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA