I have an error in my regex, that somebody wrote for me. I've tried to write my own regex but this is just to hard for me to crack.
I have a custom "tag" like {module:agenda:getlist:params(2)} But.. if I only have 1 param the regex doesn't see the 2 but gets the wrong code.
This is my regex code
$paramcount = preg_match_all('{
# [^,]+ everything that isn't a comma
# (?<=...) is a look behind. Meaning that the part that has the 3 dots
# becomes matched but not goes through the rest of the regex
# matches "null" in "params(null"
(?<=params\()[^,]+
| # this is the separation dash
# (?=...) is a look ahead, same as the look behind but than on the end
# matches "null" in " null)"
(?<= )[^,]+(?=\))
|
# matches "true" in ", true" and ""foo"" in ", "foo""
(?<=, )[^,]+
}x', $data, $parammatches);
So when I try to match it.. the outcome is:
$array = array
(
[0] => params(2
);
This is not what i want, i only want the 2 to be matched not the rest. When i give it more params like this "params(null, 2)" everything works out and i have 2 nice array values.
Can somebody guide me or help me out here.
EDIT: More output can be found on pastebin. http://pastebin.com/x0WL9K4u