Page 1 of 1

Regular Expression to Find Day of Week

Posted: Sun Aug 11, 2002 12:31 am
by mwaw
I want to search text strings to see if they start with a day of the week (Monday or Tuesday or Wednesday, etc.)

Among other things, I've tried ^(Monday)*(Tuesday)*(Wednesday)...... but the problem is how to end it. Or, perhaps I just need a different approach.

Would it actually be a better idea to put the days of the week in an array and loop throught the array to see if any of the elements match the first word of the string?

Thanks!

Mike Wilkinson

Regular Expression

Posted: Sun Aug 11, 2002 2:41 am
by Takuma
^(Monday|Tuesday|Wednesday|Thurday|Friday|Saturday|Sunday)$

I think that's it... If you want to learn more about Regular Expression check this out:-
http://www.phpbuilder.com/columns/dario19990616.php3

Posted: Sun Aug 11, 2002 11:45 am
by MattF
That will see if the string is a day of the week to see if it starts with a day of the week knock of the $ and use eregi so it is case insensitive.

Thanks for the tips!

Posted: Sun Aug 11, 2002 5:05 pm
by mwaw
Thanks for the tips.

For some reason my reference did not have any info on the OR function, so I didn't know that it was available.

Mike Wilkinson