I need to create a formatting documentation. I know the regex that are used to format the text but I don’t know how to reproduce an example for that regex.
This one should be an internal link:
'{\[((?:\#|/)[^ ]*) ([^]]*)\]}'
Can anyone create an example that would match this, and maybe explain how he got it. I got stuck at ‘?’.
I never used this meta-character at the beginning, usually I use it to mark that an literal cannot appear or appear exactly once.
Thanks
(?:...)has the same grouping effect as(...), but without “capturing” the contents of the group; see http://php.net/manual/en/regexp.reference.subpatterns.php.So,
(?:\#|/)means “either#or/“.I’m guessing you know that
[^ ]*means “zero or more characters that aren’t SP”, and that[^]]*means “zero or more characters that aren’t right-square-brackets”.Putting it together, one possible string is this: