I want to parse a string like a shortcode that can have or not variables, and put these variables in a array. The given text is:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur pulvinar erat quis aliquet pulvinar. Vivamus egestas eros at augue dictum, {mycode var1=foo|var2=zoo|var3=123a|othervarname=digit} a ultrices nisl ullamcorper. Nullam condimentum orci eros, non ornare magna accumsan in.
My regex now is:
{mycode\s?(?:(?:(\w+)\={1}(\w+)))*\|?\}*
Result is:
Array
(
[0] => Array
(
[0] => {mycode var1=foo|
)
[1] => Array
(
[0] => var1
)
[2] => Array
(
[0] => foo
)
)
I want this type of array:
Array
(
[0] => Array
(
[0] => var1
[1] => foo
)
[1] => Array
(
[0] => var2
[1] => zoo
)
[2] => Array
(
[0] => var3
[1] => 123a
)
[3] => Array
(
[0] => othervarname
[1] => digit
)
)
Or:
Array
(
[0] => Array
(
[var1] => foo
)
[1] => Array
(
[var2] => zoo
)
[2] => Array
(
[var3] => 123a
)
[3] => Array
(
[othervarname] => digit
)
)
Thank you very much. Serafino
{mycode\s?(?:(?:(\w+)\=(\w+)))*\|?\}*is the same regex as yours but simplified a bittest {mycode var1=foo} and another code {mycode var2=foo2}?