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

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

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -