Page 1 of 1

PHP Wildcard usage in searching text files

Posted: Tue Dec 20, 2005 11:57 am
by ZandarKoad
I've done extensive searching, and every topic on wildcards shows how they work with SQL or in a file system. But I'm trying to use a wild card to search (using strstr()) a text file for the locations of DATES, with the format: xx/xx/xx. Here's the code:

Code: Select all

<? if (strstr($TextData, "##/##/##")){
	echo "A date has been found";}
 echo strstr($TextData, "##/##/##");?>
I've tried #, *, %, with and without single and double quotes (without the quotes, PHP won't parse it). Every time I DO use the quotes, it's going to look for a literal # or * or %! Its a loose loose situation. How would I go about syntaxing the wildcards in this situation?

Posted: Tue Dec 20, 2005 12:05 pm
by Burrito
you're going to need a regular expression for that. there isn't a wildcard 'feature' for searching strings from textfiles or from php strings in general.

Posted: Tue Dec 20, 2005 12:08 pm
by ZandarKoad
Thanks for the quick reply.
Now I go weep and cry.

Posted: Tue Dec 20, 2005 12:11 pm
by Burrito
don't cry.

we can help you with some regex if need be :D