php regex - can't find the error

Posted by peirix on Stack Overflow See other posts from Stack Overflow or by peirix
Published on 2010-06-01T09:09:20Z Indexed on 2010/06/01 9:13 UTC
Read the original article Hit count: 275

Filed under:
|

Just one simple, specific question:
I've got the string {var1}12345{var2}, and I want to get the variable names used.

if (preg_match("/{([a-zA-Z0-9]*)}/g", $url, $matches)) {
    print_r($matches);
}

If I remove the global flag, it works, but I only get the first variable, as expected. Why isn't it working with a global flag? It works when I'm testing it with the Regex Tester

© Stack Overflow or respective owner

Related posts about php

Related posts about regex