I want to match nested Wiki functions or wiki parser functions that start with a functionname and then a colon, but as soon as I try to get the recursive pcre regex working with a 1st level test I fail to construct a regex pattern. I want to match with the test that it starts with {{aFunctionName:
followed by colon, in regex {{[\w\d]+:
the test text can look like
1 {{DEFAULTSORT: shall be matched {{PAGENAME}} }}
2 {{DEFAULTSORT: shall be matched }}
3 {{DEFAULTSORT: shall be matched {{PAGENAMEE: some text}} }}
4 Lorem ipsum {{VARIABLE shall not be matched}}
5 {{Some template|param={{VARIABLE}} shall not be matched }}
I'm able to
- to get any nested curly braces using
{{(?:(?:(?!{{|}}).)++|(?R))*}}
which gets line 1, 2, 3, partially 4 and 5 - to get any nested wiki function using
({{(?:[\w\d]+:)(?:(?:(?!{{|}}).)++|(?1))*}})
which only gets line 3 but I also want to match lines 1 and 2.
But I have no idea how to construct a regex pattern that tests something like (written as pseudo code):
{{match1st-level-Function: then anything {{nested}} or not nested }}
{{do not match simple {{nested}} things}}
Any help from a pcre regex expert? Thank you!