Regular Expressions 101

Save & Share

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

Flavor

  • PCRE2 (PHP >=7.3)
  • PCRE (PHP <7.3)
  • ECMAScript (JavaScript)
  • Python
  • 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{2}(?=.((?!\8)[_\/])\11)\Q(_\E.\4{2}(?!\.)\5((?!\10)(?10)(?!\4+|\5|\6))\1\3{3}(\\) (\3{3})\13\2{2}\1{1}\3+(?<=\S {10})\4\1\3\| \1(?=\12)(?12)(?!`,)\10\4(\11{2})\4\14\10\15\9\8 \14{2}(?=\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{2}(?=.((?!\8)[_\/])\11)\Q(_\E.\4{2}(?!\.)\5((?!\10)(?10)(?!\4+|\5|\6))\1\3{3}(\\) (\3{3})\13\2{2}\1{1}\3+(?<=\S {10})\4\1\3\| \1(?=\12)(?12)(?!`,)\10\4(\11{2})\4\14\10\15\9\8 \14{2}(?=\6)['-]\4(?<!-)\11\8\11\4\6\11\15\.-
^ asserts position at start of the string
1st Capturing Group
( *)
matches the character with index 3210 (2016 or 408) literally (case sensitive)
2nd Capturing Group
( *)
matches the character with index 3210 (2016 or 408) literally (case sensitive)
3rd Capturing Group
( *)
matches the character with index 3210 (2016 or 408) literally (case sensitive)
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
\4 matches the same text as most recently matched by the 4th capturing group
2nd Alternative
\5
\5 matches the same text as most recently matched by the 5th capturing group
(?4)
recurses the 4th subpattern
++ matches the previous token between one and unlimited times, as many times as possible, without giving back (possessive)
\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
. matches any character (except for line terminators)
7th Capturing Group
(.)
. matches any character (except for line terminators)
\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
1st Alternative
\4
\4 matches the same text as most recently matched by the 4th capturing group
2nd Alternative
\6
\6 matches the same text as most recently matched by the 6th capturing group
8th Capturing Group
([_\/])
Match a single character present in the list below
[_\/]
_ matches the character _ with index 9510 (5F16 or 1378) literally (case sensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
\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
(?11) recurses the 11th subpattern
\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 _ with index 9510 (5F16 or 1378) 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 with index 1010 (A16 or 128) 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 with index 1010 (A16 or 128) literally (case sensitive)
14th Capturing Group
(\3{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 {10})
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 | with index 12410 (7C16 or 1748) literally (case sensitive)
matches the character with index 1010 (A16 or 128) 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{2})
\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 with index 1010 (A16 or 128) 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 . with index 4610 (2E16 or 568) literally (case sensitive)
- matches the character - with index 4510 (2D16 or 558) 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

Code Generator

Generated Code

Loading code sample...
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report.
For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html