simple regular expression problem

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
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

simple regular expression problem

Post by yacahuma »

Code: Select all

$pattern = "/\[[0-9]*\]/";
preg_match($pattern, "sdsds[923232] sdsdsds[1112222]", $matches, PREG_OFFSET_CAPTURE);
print_r($matches);
The output
Array ( [0] => Array ( [0] => [923232] [1] => 5 ) )

Why do I only get one match and not 2????

What am I doing wrong??
Thank you
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

use preg_match_all()
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Thank you that worked(JEJE)

Post by yacahuma »

Thank you that worked.
Post Reply