PHP: preg_match_all - Couldn't write a working RegEx -


i have example string \try tester234 want find word (partially digits) (regex => (\w|\d)) after \try. var_dump($match) outputs that:

array   0 =>      array       empty   1 =>      array       empty 

preg_match_all('/^\\try ((\d|\w)*)/i', "\try tester", $match); 

what doing wrong?

you need 4 backslashes insert literal 1 in regular expression:

preg_match_all('/^\\\\block ((\d|\w)*)/i', "\block tester", $match); 

which maybe better written this:

preg_match_all('/^\\\\block (\w+)/i', "\block tester", $match); 

Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -