Regular Expressions 101

Save & Share

Flavor

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

Function

  • Match
  • Substitution
  • List
  • Unit Tests
/
(?:(?:and|or|<<|>>>?|(?<!\()\/|[=!<>*%+\-&^])?=(?!>)|[!%&^*\/~<>?|:]|\-?\-(?!>)|\+\+?|<>|&&|\.\.\.?|\|\||\b(?<![\.\$])(instanceof|new|delete|typeof|and|or|is|isnt|not|super)(?!\s*:)\b)
/
g
Non-capturing group
(?:(?:and|or|<<|>>>?|(?<!\()\/|[=!<>*%+\-&^])?=(?!>)|[!%&^*\/~<>?|:]|\-?\-(?!>)|\+\+?|<>|&&|\.\.\.?|\|\||\b(?<![\.\$])(instanceof|new|delete|typeof|and|or|is|isnt|not|super)(?!\s*:)\b)
1st Alternative
(?:and|or|<<|>>>?|(?<!\()\/|[=!<>*%+\-&^])?=(?!>)
Non-capturing group
(?:and|or|<<|>>>?|(?<!\()\/|[=!<>*%+\-&^])?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
1st Alternative
and
and
matches the characters and literally (case sensitive)
2nd Alternative
or
or
matches the characters or literally (case sensitive)
3rd Alternative
<<
<<
matches the characters << literally (case sensitive)
4th Alternative
>>>?
>>
matches the characters >> literally (case sensitive)
>
matches the character > with index 6210 (3E16 or 768) literally (case sensitive)
5th Alternative
(?<!\()\/
Negative Lookbehind
(?<!\()
Assert that the Regex below does not match
\( matches the character ( with index 4010 (2816 or 508) literally (case sensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
6th Alternative
[=!<>*%+\-&^]
Match a single character present in the list below
[=!<>*%+\-&^]
=!<>*%+
matches a single character in the list =!<>*%+ (case sensitive)
\- matches the character - with index 4510 (2D16 or 558) literally (case sensitive)
&^
matches a single character in the list &^ (case sensitive)
= matches the character = with index 6110 (3D16 or 758) literally (case sensitive)
Negative Lookahead
(?!>)
Assert that the Regex below does not match
> matches the character > with index 6210 (3E16 or 768) literally (case sensitive)
2nd Alternative
[!%&^*\/~<>?|:]
Match a single character present in the list below
[!%&^*\/~<>?|:]
!%&^*
matches a single character in the list !%&^* (case sensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
~<>?|:
matches a single character in the list ~<>?|: (case sensitive)
3rd Alternative
\-?\-(?!>)
\-
matches the character - with index 4510 (2D16 or 558) literally (case sensitive)
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
\- matches the character - with index 4510 (2D16 or 558) literally (case sensitive)
Negative Lookahead
(?!>)
Assert that the Regex below does not match
> matches the character > with index 6210 (3E16 or 768) literally (case sensitive)
4th Alternative
\+\+?
\+ matches the character + with index 4310 (2B16 or 538) literally (case sensitive)
\+
matches the character + with index 4310 (2B16 or 538) literally (case sensitive)
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
5th Alternative
<>
<>
matches the characters <> literally (case sensitive)
6th Alternative
&&
&&
matches the characters && literally (case sensitive)
7th Alternative
\.\.\.?
\. matches the character . with index 4610 (2E16 or 568) literally (case sensitive)
\. matches the character . with index 4610 (2E16 or 568) literally (case sensitive)
\.
matches the character . with index 4610 (2E16 or 568) literally (case sensitive)
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
8th Alternative
\|\|
\| matches the character | with index 12410 (7C16 or 1748) literally (case sensitive)
\| matches the character | with index 12410 (7C16 or 1748) literally (case sensitive)
9th Alternative
\b(?<![\.\$])(instanceof|new|delete|typeof|and|or|is|isnt|not|super)(?!\s*:)\b
\b assert position at a word boundary: (^\w|\w$|\W\w|\w\W)
Negative Lookbehind
(?<![\.\$])
Assert that the Regex below does not match
Match a single character present in the list below
[\.\$]
\. matches the character . with index 4610 (2E16 or 568) literally (case sensitive)
\$ matches the character $ with index 3610 (2416 or 448) literally (case sensitive)
1st Capturing Group
(instanceof|new|delete|typeof|and|or|is|isnt|not|super)
1st Alternative
instanceof
instanceof
matches the characters instanceof literally (case sensitive)
2nd Alternative
new
new
matches the characters new literally (case sensitive)
3rd Alternative
delete
4th Alternative
typeof
5th Alternative
and
6th Alternative
or
7th Alternative
is
8th Alternative
isnt
9th Alternative
not
10th Alternative
super
Negative Lookahead
(?!\s*:)
Assert that the Regex below does not match
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
: matches the character : with index 5810 (3A16 or 728) literally (case sensitive)
\b assert position at a word boundary: (^\w|\w$|\W\w|\w\W)
Global pattern flags
g modifier: global. All matches (don't return after first match)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
g

Test String