Re: regular expressions (maybe) :-)

From: Date: Mon, 06 Nov 2000 00:47:21 +0000
Subject: Re: regular expressions (maybe) :-)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-23820@lists.php.net to get a copy of this message
Hi Jeff, preg_match will do what you are looking for: preg_match("/stole\d+/",$text,$matches); $text contains the text to search against, $matches will contain the matches. See the manual for detail info on the structure of $matches. Monte Jeff Lacy wrote: > Hello world, > > I need to know how many 'stole[number goes here]'s are in a string. I have no idea > how to do this, but I suspect it might involve regular expressions. Regular expressions make my > head spin. I don't even know if I am on the right track. If you would please help me by > telling me what I could use, I would be very grateful. An example of a string I might have would be > > > $string = "stole1 & stole2 & stole3 & stole4 & stoled1"; > > What ever happens, somehow, I would like to end up with 4 because I am only looking for stole > and a number. stoled and a number should be different. > > Thank you very much. I appreciate it a lot. > > Jeff

« previous php.general (#23820) next »