Regular Expressions 101

@regex101
Donate
Sponsor
Contact
Bug Reports & Feedback
Wiki
Whats new?

Save & Share

  • Save Regex
    ctrl+s
  • Update Regex
    ctrl+⇧+s

Flavor

  • PCRE2 (PHP >=7.3)
  • PCRE (PHP <7.3)
  • ECMAScript (JavaScript)
  • Python 2.7
  • Golang
  • Java 8

Function

  • Match
  • Substitution
  • List
  • Unit Tests
~
((?:\[\s(?<name>[a-zA-Z0-9-_])\s(?:\=\s(?<bbCode>\"(?:[^\"\\\\](?:\\\\.[^\"\\\\])*)\"|((?:(?!=\s|\]|\/\])[^\s])+)))?\s(?<parameters>(?:\s(?:\w(?:\s\=\s\"(?:[^\"\\\\](?:\\\\.[^\"\\\\])*)\"|\s\=\s((?:(?!=\s|\]|\/\])[^\s])+)|(?=\s|\]|\/\s\]|$))))*)\s(?:\](?<content>.)\[\s(?<markerContent>\/)\s(\k<name>)\s\]|\]|(?<marker>\/)\s\])))
~
ugmi
1st Capturing Group
((?:\[\s(?<name>[a-zA-Z0-9-_])\s(?:\=\s(?<bbCode>\"(?:[^\"\\\\](?:\\\\.[^\"\\\\])*)\"|((?:(?!=\s|\]|\/\])[^\s])+)))?\s(?<parameters>(?:\s(?:\w(?:\s\=\s\"(?:[^\"\\\\](?:\\\\.[^\"\\\\])*)\"|\s\=\s((?:(?!=\s|\]|\/\])[^\s])+)|(?=\s|\]|\/\s\]|$))))*)\s(?:\](?<content>.)\[\s(?<markerContent>\/)\s(\k<name>)\s\]|\]|(?<marker>\/)\s\])))
Non-capturing group
(?:\[\s(?<name>[a-zA-Z0-9-_])\s(?:\=\s(?<bbCode>\"(?:[^\"\\\\](?:\\\\.[^\"\\\\])*)\"|((?:(?!=\s|\]|\/\])[^\s])+)))?\s(?<parameters>(?:\s(?:\w(?:\s\=\s\"(?:[^\"\\\\](?:\\\\.[^\"\\\\])*)\"|\s\=\s((?:(?!=\s|\]|\/\])[^\s])+)|(?=\s|\]|\/\s\]|$))))*)\s(?:\](?<content>.)\[\s(?<markerContent>\/)\s(\k<name>)\s\]|\]|(?<marker>\/)\s\]))
\[ matches the character [ literally (case insensitive)
\s
matches any kind of invisible character (equivalent to [\p{Z}\h\v])
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
Named Capture Group name
(?<name>[a-zA-Z0-9-_])
Match a single character present in the list below
[a-zA-Z0-9-_]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
a-z matches a single character in the range between a (index 97) and z (index 122) (case insensitive)
A-Z matches a single character in the range between A (index 65) and Z (index 90) (case insensitive)
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case insensitive)
- matches the character - literally (case insensitive)
This hyphen is treated literally, which might be confusing for others. Consider escaping it or placing at the start or end of the class!
_ matches the character _ literally (case insensitive)
\s
matches any kind of invisible character (equivalent to [\p{Z}\h\v])
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
Non-capturing group
(?:\=\s(?<bbCode>\"(?:[^\"\\\\](?:\\\\.[^\"\\\\])*)\"|((?:(?!=\s|\]|\/\])[^\s])+)))?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
\= matches the character = literally (case insensitive)
\s
matches any kind of invisible character (equivalent to [\p{Z}\h\v])
Named Capture Group bbCode
(?<bbCode>\"(?:[^\"\\\\](?:\\\\.[^\"\\\\])*)\"|((?:(?!=\s|\]|\/\])[^\s])+))
\s
matches any kind of invisible character (equivalent to [\p{Z}\h\v])
Named Capture Group parameters
(?<parameters>(?:\s(?:\w(?:\s\=\s\"(?:[^\"\\\\](?:\\\\.[^\"\\\\])*)\"|\s\=\s((?:(?!=\s|\]|\/\])[^\s])+)|(?=\s|\]|\/\s\]|$))))*)
\s
matches any kind of invisible character (equivalent to [\p{Z}\h\v])
Non-capturing group
(?:\](?<content>.)\[\s(?<markerContent>\/)\s(\k<name>)\s\]|\]|(?<marker>\/)\s\])
Global pattern flags
u modifier: unicode. Pattern strings are treated as UTF-16. Also causes escape sequences to match unicode characters
g modifier: global. All matches (don't return after first match)
m modifier: multi line. Causes ^ and $ to match the begin/end of each line (not only begin/end of string)
i modifier: insensitive. Case insensitive match (ignores case of [a-zA-Z])
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

~
~
ugmi

Test String