I am currently trying to extract a numeric value from an html string. I am currently using preg_match but to no luck. All I desire is to get the numeric value set as param of a javascript function myFunction. As of now I get an empty array. Any help to achieve this?
$data = "<th style='text-align:center;width:33%;'><a onclick='return myfunction(12314568);' href='#test' class='btn mini full'>Test</a> </th>";
preg_match("/\[return myfunction([0-9]+)\]/", $data, $m);
print_r($m);
(and)have special meaning in regex, so you must escape them. second, where the heck are you getting the[and]from? if you remove those, and escape the () , your regex works fine. 3v4l.org/8qvnH