I've been working on this for quite some time, but I would need to learn the regex first, and I will do it next. This can be a good example for other people, so how could something like this be explained?
(?: [^[] | \[ (?! /?indent] ) | (?R) )
(?: ...) - this is a non-capturing group, the whole thing here
[^[] - match anything that is not the "["
| - OR ("22|33"; this will match either "22" or "23")
(?! ...) - negative lookahead. Specifies a group that cannot match after the main expression (if it matches the result is discarded); (?!theatre)the\w+ - matches “theme” but not “theater”
/? - /? – once or none; plurals?, matches plural, plurals
I was reading about recursion, but I still dont understand this part in this context.
I guess we are looking for "[indent]" and "[/indent]" overall, but with all the above context that I dont fully get. This is taken from an example at php.net:
http://php.net/manual/pl/function.preg-replace-callback.php Example #3
Thanks.