I need to parse string
{name "some" 'words' `or` '}\'other staff' in:0 line:`\`}
into
array("some","words","or","}'other staff","in"=>0, "line"=>"\\")
, but preg returns only one match for template, can i do something to get all matches? here is my regex:
!\{
(\#?[a-zA-Z0-9\_]{1,16})
(\.[a-zA-Z0-9\_]{1,16})?
(?P<args>(?P<arg>
\ +([a-zA-Z0-9\_]{1,16}\:)?
\'(\\\\|\\\'|[^\'])*?\'| //argument in singlequote
\"([^\\\"]|\\.)*?\"| //argument in doublequote
\`[^\`]*?\`| //argument in backquote
[0-9]*(\.[0-9]*)? //argument numeral
)*?)\ *\}!
and i get this:
array(1) {
[0]=>
array(12) {
[0]=>
string(57) "{name "some" 'words' `or` '}\'other staff' in:0 line:`\`}"
[1]=>
string(4) "name"
[2]=>
string(0) ""
["args"]=>
string(51) " "some" 'words' `or` '}\'other staff' in:0 line:`\`"
[3]=>
string(51) " "some" 'words' `or` '}\'other staff' in:0 line:`\`"
[4]=>
string(9) " line:`\`"
["arg"]=>
string(8) "line:`\`" //last argument
[5]=>
string(8) "line:`\`"
[6]=>
string(5) "line:"
[7]=>
string(3) "`\`"
[8]=>
string(1) "f"
[9]=>
string(1) "e"
}
}
how can i get array of arguments, not the last one?