PHP Wildcard usage in searching text files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ZandarKoad
Forum Newbie
Posts: 2
Joined: Tue Dec 20, 2005 11:45 am

PHP Wildcard usage in searching text files

Post 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?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post 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.
ZandarKoad
Forum Newbie
Posts: 2
Joined: Tue Dec 20, 2005 11:45 am

Post by ZandarKoad »

Thanks for the quick reply.
Now I go weep and cry.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

don't cry.

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