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
/
^( )( )( )(['.-])((?!\4)(?4))((?!\4|\5)(?4))\1\3whale (?=.(.))\6.\7\4(?!\4|\6)([_\/])\3(?!(?11))\8\2(?=\2)\3\1_((?=\4.).\5(?!\6)\5)(?!.')\7\4 (?=.\7)\6.([,`])\3(?=.((?!\8)[_\/])\11)\Q(_\E.\4(?!\.)\5((?!\10)(?10)(?!\4|\5|\6))\1\3(\\) (\3)\13\2\1\3(?<=\S )\4\1\3\| \1(?=\12)(?12)(?!`,)\10\4(\11)\4\14\10\15\9\8 \14(?=\6)['-]\4(?<!-)\11\8\11\4\6\11\15\.-|(?!)
/
1st Alternative
^( )( )( )(['.-])((?!\4)(?4))((?!\4|\5)(?4))\1\3whale (?=.(.))\6.\7\4(?!\4|\6)([_\/])\3(?!(?11))\8\2(?=\2)\3\1_((?=\4.).\5(?!\6)\5)(?!.')\7\4 (?=.\7)\6.([,`])\3(?=.((?!\8)[_\/])\11)\Q(_\E.\4(?!\.)\5((?!\10)(?10)(?!\4|\5|\6))\1\3(\\) (\3)\13\2\1\3(?<=\S )\4\1\3\| \1(?=\12)(?12)(?!`,)\10\4(\11)\4\14\10\15\9\8 \14(?=\6)['-]\4(?<!-)\11\8\11\4\6\11\15\.-
^ asserts position at start of the string
1st Capturing Group
( )
matches the character literally (case sensitive)
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
2nd Capturing Group
( )
matches the character literally (case sensitive)
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
3rd Capturing Group
( )
matches the character literally (case sensitive)
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
4th Capturing Group
(['.-])
Match a single character present in the list below
['.-]
'.- matches a single character in the list '.- (case sensitive)
5th Capturing Group
((?!\4)(?4))
Negative Lookahead
(?!\4)
Assert that the Regex below does not match
\4 matches the same text as most recently matched by the 4th capturing group
(?4)
recurses the 4th subpattern
+? matches the previous token between one and unlimited times, as few times as possible, expanding as needed (lazy)
6th Capturing Group
((?!\4|\5)(?4))
Negative Lookahead
(?!\4|\5)
Assert that the Regex below does not match
1st Alternative
\4
2nd Alternative
\5
(?4)
recurses the 4th subpattern
\1 matches the same text as most recently matched by the 1st capturing group
\3 matches the same text as most recently matched by the 3rd capturing group
whale matches the characters whale literally (case sensitive)
Positive Lookahead
(?=.(.))
Assert that the Regex below matches
\6 matches the same text as most recently matched by the 6th capturing group
. matches any character (except for line terminators)
\7 matches the same text as most recently matched by the 7th capturing group
\4 matches the same text as most recently matched by the 4th capturing group
Negative Lookahead
(?!\4|\6)
Assert that the Regex below does not match
8th Capturing Group
([_\/])
\3 matches the same text as most recently matched by the 3rd capturing group
Negative Lookahead
(?!(?11))
Assert that the Regex below does not match
\8 matches the same text as most recently matched by the 8th capturing group
\2 matches the same text as most recently matched by the 2nd capturing group
Positive Lookahead
(?=\2)
Assert that the Regex below matches
\3 matches the same text as most recently matched by the 3rd capturing group
\1 matches the same text as most recently matched by the 1st capturing group
_ matches the character _ literally (case sensitive)
9th Capturing Group
((?=\4.).\5(?!\6)\5)
Negative Lookahead
(?!.')
Assert that the Regex below does not match
\7 matches the same text as most recently matched by the 7th capturing group
\4 matches the same text as most recently matched by the 4th capturing group
matches the character literally (case sensitive)
Positive Lookahead
(?=.\7)
Assert that the Regex below matches
\6 matches the same text as most recently matched by the 6th capturing group
. matches any character (except for line terminators)
10th Capturing Group
([,`])
\3
matches the same text as most recently matched by the 3rd capturing group
Positive Lookahead
(?=.((?!\8)[_\/])\11)
Assert that the Regex below matches
\Q(_\E matches the characters (_ literally (case sensitive)
. matches any character (except for line terminators)
\4
matches the same text as most recently matched by the 4th capturing group
Negative Lookahead
(?!\.)
Assert that the Regex below does not match
\5 matches the same text as most recently matched by the 5th capturing group
12th Capturing Group
((?!\10)(?10)(?!\4|\5|\6))
\1 matches the same text as most recently matched by the 1st capturing group
\3
matches the same text as most recently matched by the 3rd capturing group
13th Capturing Group
(\\)
matches the character literally (case sensitive)
14th Capturing Group
(\3)
\13 matches the same text as most recently matched by the 13th capturing group
\2
matches the same text as most recently matched by the 2nd capturing group
\1
matches the same text as most recently matched by the 1st capturing group
\3
matches the same text as most recently matched by the 3rd capturing group
Positive Lookbehind
(?<=\S )
Assert that the Regex below matches
\4 matches the same text as most recently matched by the 4th capturing group
\1 matches the same text as most recently matched by the 1st capturing group
\3 matches the same text as most recently matched by the 3rd capturing group
\| matches the character | literally (case sensitive)
matches the character literally (case sensitive)
\1 matches the same text as most recently matched by the 1st capturing group
Positive Lookahead
(?=\12)
Assert that the Regex below matches
(?12) recurses the 12th subpattern
Negative Lookahead
(?!`,)
Assert that the Regex below does not match
\10 matches the same text as most recently matched by the 10th capturing group
\4 matches the same text as most recently matched by the 4th capturing group
15th Capturing Group
(\11)
\4 matches the same text as most recently matched by the 4th capturing group
\14 matches the same text as most recently matched by the 14th capturing group
\10 matches the same text as most recently matched by the 10th capturing group
\15 matches the same text as most recently matched by the 15th capturing group
\9 matches the same text as most recently matched by the 9th capturing group
\8 matches the same text as most recently matched by the 8th capturing group
matches the character literally (case sensitive)
\14
matches the same text as most recently matched by the 14th capturing group
Positive Lookahead
(?=\6)
Assert that the Regex below matches
Match a single character present in the list below
['-]
\4 matches the same text as most recently matched by the 4th capturing group
Negative Lookbehind
(?<!-)
Assert that the Regex below does not match
\11 matches the same text as most recently matched by the 11th capturing group
\8 matches the same text as most recently matched by the 8th capturing group
\11 matches the same text as most recently matched by the 11th capturing group
\4 matches the same text as most recently matched by the 4th capturing group
\6 matches the same text as most recently matched by the 6th capturing group
\11 matches the same text as most recently matched by the 11th capturing group
\15 matches the same text as most recently matched by the 15th capturing group
\. matches the character . literally (case sensitive)
- matches the character - literally (case sensitive)
2nd Alternative
(?!)
Negative Lookahead
(?!)
null, matches any position
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/

Test String