i try to build a small system that catches variables from html template.
the variables defined as @XXX@ and may (but not required) to have extra parameters that are sent with colon (:), i.e. @XXX@:j to send the data as json encoded.
what i manage to do is to create a preg_match_all to capture the variables and those extra parameters. so i came up with this preg:
preg_match_all("/(@.*@(?:(j|n|x|z))?)/imU", $string,$this->localVariables,PREG_PATTERN_ORDER);
j|n|x|z are the avialiable extra parameters that are possible.
the string that i send to $string is: @geterr@ @domain@:j @jhon@:n
the result i get from preg_match_all is:
Array
(
[0] => Array
(
[0] => @geterr@
[1] => @domain@
[2] => @jhon@
)
[1] => Array
(
[0] => @geterr@
[1] => @domain@
[2] => @jhon@
)
[2] => Array
(
[0] =>
[1] =>
[2] =>
)
)
i know (or think i know) that ?: is used for optional sub pattern the modifires iv'e used are: i for case insensitive m for to allow my string to be multiline U - to be non greedy
i have no other clue what i do wrong.
any help shall be greatly appriciated