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
/
^(?=^([^)(]\(((?>[^)(])|(?1))*\)[^)(])*$)(?=^([^][]\[((?>[^][])|(?3))*\][^][])*$)(?=^([^}{]\{((?>[^}{])|(?5))*\}[^}{])*$)(?!^\(.)(?!.\(.\).)(?=.\[.\].)(?=.\{.\}.)(?=.\[.\(\).\{\}.\].)(?=.\}...\[...\[...\]...\]...\{.)(?=.\(\(..\(\(.\(\(\)\).\)\)\)\).)(?=.\{..\{..\{.\{\}\{\}.\{\}.\}\}.\}.)(?=.\[\{\{\[\(\{.)(?=.\[\[..\[.\[.\]\]...\]\].\[..\]..\[\].)(?=.\]\]\}\}\}.\)\)\)\).\]\}\}\]\]\]\}\]\]\].\)\]\].)(?=.\]..\).\(.\{.\[...\[.\{\[.)(?=.\[.\{.}{.}.\].)(?=.\(\{.\(.\{.\].\{\{.\}\}.\].\}....\}.\).)(?=.\{.\(.\(...\(...\{\[.\{\[\[.)(?=.\{\(.\).\}.\[.\]..\{.\{\}....\}.)(?=.\(.\{.\{.\}.\}.\).)(?!.\(\{\(\(.)(?!.\(\)\[\].)(?=(.\].\)){15,}.)(?=(.\[.\(.\{){5,9}.)(?=.\(.\[.[^}{].)(?=.\(..\).\(\)....\}\}\].\{\{\[.\[.\}\}\].)(?!.\(\(.\])(?=(.\[..\]){8,10}.)(?!(.\([^\(\)]\(){4,}.).(.).\11.$
/
^ asserts position at start of the string
Positive Lookahead
(?=^([^)(]\(((?>[^)(])|(?1))*\)[^)(])*$)
Assert that the Regex below matches
^ asserts position at start of the string
1st Capturing Group
([^)(]\(((?>[^)(])|(?1))*\)[^)(])*
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
A repeated capturing group will only capture the last iteration. Put a capturing group around the repeated group to capture all iterations or use a non-capturing group instead if you're not interested in the data
Match a single character not present in the list below
[^)(]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
)( matches a single character in the list )( (case sensitive)
\( matches the character ( literally (case sensitive)
2nd Capturing Group
((?>[^)(])|(?1))*
\) matches the character ) literally (case sensitive)
Match a single character not present in the list below
[^)(]
$ asserts position at the end of the string, or before the line terminator right at the end of the string (if any)
Positive Lookahead
(?=^([^][]\[((?>[^][])|(?3))*\][^][])*$)
Assert that the Regex below matches
^ asserts position at start of the string
3rd Capturing Group
([^][]\[((?>[^][])|(?3))*\][^][])*
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
A repeated capturing group will only capture the last iteration. Put a capturing group around the repeated group to capture all iterations or use a non-capturing group instead if you're not interested in the data
Match a single character not present in the list below
[^][]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
][ matches a single character in the list ][ (case sensitive)
\[ matches the character [ literally (case sensitive)
4th Capturing Group
((?>[^][])|(?3))*
\] matches the character ] literally (case sensitive)
Match a single character not present in the list below
[^][]
$ asserts position at the end of the string, or before the line terminator right at the end of the string (if any)
Positive Lookahead
(?=^([^}{]\{((?>[^}{])|(?5))*\}[^}{])*$)
Assert that the Regex below matches
^ asserts position at start of the string
5th Capturing Group
([^}{]\{((?>[^}{])|(?5))*\}[^}{])*
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
A repeated capturing group will only capture the last iteration. Put a capturing group around the repeated group to capture all iterations or use a non-capturing group instead if you're not interested in the data
Match a single character not present in the list below
[^}{]
\{ matches the character { literally (case sensitive)
6th Capturing Group
((?>[^}{])|(?5))*
\} matches the character } literally (case sensitive)
Match a single character not present in the list below
[^}{]
$ asserts position at the end of the string, or before the line terminator right at the end of the string (if any)
Negative Lookahead
(?!^\(.)
Assert that the Regex below does not match
^ asserts position at start of the string
\( matches the character ( literally (case sensitive)
.
matches any character (except for line terminators)
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
Negative Lookahead
(?!.\(.\).)
Assert that the Regex below does not match
.
matches any character (except for line terminators)
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
\( matches the character ( literally (case sensitive)
.
matches any character (except for line terminators)
\) matches the character ) literally (case sensitive)
.
matches any character (except for line terminators)
Positive Lookahead
(?=.\[.\].)
Assert that the Regex below matches
.
matches any character (except for line terminators)
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
\[ matches the character [ literally (case sensitive)
.
matches any character (except for line terminators)
\] matches the character ] literally (case sensitive)
.
matches any character (except for line terminators)
Positive Lookahead
(?=.\{.\}.)
Assert that the Regex below matches
.
matches any character (except for line terminators)
\{ matches the character { literally (case sensitive)
.
matches any character (except for line terminators)
\} matches the character } literally (case sensitive)
.
matches any character (except for line terminators)
Positive Lookahead
(?=.\[.\(\).\{\}.\].)
Assert that the Regex below matches
.
matches any character (except for line terminators)
\[ matches the character [ literally (case sensitive)
. matches any character (except for line terminators)
\( matches the character ( literally (case sensitive)
\) matches the character ) literally (case sensitive)
. matches any character (except for line terminators)
\{ matches the character { literally (case sensitive)
\} matches the character } literally (case sensitive)
. matches any character (except for line terminators)
\] matches the character ] literally (case sensitive)
.
matches any character (except for line terminators)
Positive Lookahead
(?=.\}...\[...\[...\]...\]...\{.)
Assert that the Regex below matches
Positive Lookahead
(?=.\(\(..\(\(.\(\(\)\).\)\)\)\).)
Assert that the Regex below matches
Positive Lookahead
(?=.\{..\{..\{.\{\}\{\}.\{\}.\}\}.\}.)
Assert that the Regex below matches
Positive Lookahead
(?=.\[\{\{\[\(\{.)
Assert that the Regex below matches
Positive Lookahead
(?=.\[\[..\[.\[.\]\]...\]\].\[..\]..\[\].)
Assert that the Regex below matches
Positive Lookahead
(?=.\]\]\}\}\}.\)\)\)\).\]\}\}\]\]\]\}\]\]\].\)\]\].)
Assert that the Regex below matches
Positive Lookahead
(?=.\]..\).\(.\{.\[...\[.\{\[.)
Assert that the Regex below matches
Positive Lookahead
(?=.\[.\{.}{.}.\].)
Assert that the Regex below matches
Positive Lookahead
(?=.\(\{.\(.\{.\].\{\{.\}\}.\].\}....\}.\).)
Assert that the Regex below matches
Positive Lookahead
(?=.\{.\(.\(...\(...\{\[.\{\[\[.)
Assert that the Regex below matches
Positive Lookahead
(?=.\{\(.\).\}.\[.\]..\{.\{\}....\}.)
Assert that the Regex below matches
Positive Lookahead
(?=.\(.\{.\{.\}.\}.\).)
Assert that the Regex below matches
Negative Lookahead
(?!.\(\{\(\(.)
Assert that the Regex below does not match
Negative Lookahead
(?!.\(\)\[\].)
Assert that the Regex below does not match
Positive Lookahead
(?=(.\].\)){15,}.)
Assert that the Regex below matches
Positive Lookahead
(?=(.\[.\(.\{){5,9}.)
Assert that the Regex below matches
Positive Lookahead
(?=.\(.\[.[^}{].)
Assert that the Regex below matches
Positive Lookahead
(?=.\(..\).\(\)....\}\}\].\{\{\[.\[.\}\}\].)
Assert that the Regex below matches
Negative Lookahead
(?!.\(\(.\])
Assert that the Regex below does not match
Positive Lookahead
(?=(.\[..\]){8,10}.)
Assert that the Regex below matches
Negative Lookahead
(?!(.\([^\(\)]\(){4,}.)
Assert that the Regex below does not match
.
matches any character (except for line terminators)
11th Capturing Group
(.)
.
matches any character (except for line terminators)
\11 matches the same text as most recently matched by the 11th capturing group
.
matches any character (except for line terminators)
$ asserts position at the end of the string, or before the line terminator right at the end of the string (if any)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/

Test String