regex - Get Value from string between ":" and "," -
here example of string
"{"id":128,"order":128,"active":"1","name":"\" now need "128" - id parameter. first value between ":" , ",".
i have tried preg_match , different regular expressions i'm not in regular expressions. maybe knew how make ?
$id = preg_match('/:(,*?)\,/s', $content, $matches);
here sample code number after first : using regex:
$re = "/(?<=\\:)[0-9]+/"; $str = "\"{\"id\":128,\"order\":128,\"active\":\"1\",\"name\":\"\""; preg_match($re, $str, $matches); print $matches[0]; here sample program on tutorialspoint.
just small detail regex (?<=\\:)[0-9]+: uses fixed-width look-behind php supports, fortunately.
Comments
Post a Comment