Currently I am trying to get all function parameters with regex for templating. The function parameters will be much like PHP compitable.
So here is the sample text needed to be parsed:
"test", 'test2', $test3, ?"%A %d %B %Y", "foo,bar,foobar"
This needed to be parsed to:
[
'"test"',
'\'test2\'',
'$test3',
'?"%A %d %B %Y"',
'"foo,bar,foobar"'
]
I found this pattern but. When it has commas (,) in between double quotes it splits them too.
'~([^,]+\(.+?\))|([^,]+)~x'
The result of this pattern is:
[
'"test"',
' \'test2\'',
' $test3',
' ?"%A %d %B %Y"',
' "foo,',
'bar,',
'foobar"'
]
I am not very good with regex patterns. I can achieve basic things with it but I couldn't find a way to achieve this.