Re: preg_match() occurence position

From: Date: Thu, 25 Jul 2002 12:20:22 +0000
Subject: Re: preg_match() occurence position
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-109484@lists.php.net to get a copy of this message
On Thu, 25 Jul 2002 15:05:36 +0200, you wrote: > l> for example: > l> $mem='this is a test'; > l> preg_match('/test/', ...) should return me somehow: 10 How about this: $mem='this is a test'; if(preg_match("/(.*)test/",$mem,$matches)) { echo strlen($matches[1]); } Of course, if "test" occurs more than once then the above won't work, since regex's are "greedy"...

« previous php.general (#109484) next »