php - preg_match_all -> string: var a = 100 -
i'm trying parse string:
var = 100 var b = 150 var c = test i trying create regex:
preg_match_all('/var( )*=( )*([^\s]+)/', $code, $get_zmienne); preg_match_all('/var(\s)*=(\s)*([^\s]+)/', $code, $get_zmienne); and wrong.
have try with:
preg_match_all('/var\s*(\w+)=\s*(\s+)/', $code, $get_zmienne); this match:
var: litteral var
\s*: 0 or more white spaces
=: litteral =
(\w+): group1 contains 1 or more word characters ie:[a-za-z0-9_]
\s+: 1 or more non space character.
Comments
Post a Comment