Jump to content

[SOLVED] How do I find the position of a regex match?


jumpfroggy

Recommended Posts

I have a $subject, and a regular-expression search string $pattern.  I want to find the position of the first match of $pattern in $subject.  Basically, I want a strpos() that works with regular expressions.  If I do preg_match($pattern, $subject), it will return 0 (for no match) or 1 (for match found), but no position.  If I do preg_match($pattern, $subject, $matches), then I'll get an array of matches in $matches, but no positions.

 

Is there any way to do this?  Thanks!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.