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
/
(?=.{20}).*?(?=(?<ch>[@#$^]))(?<match>\k<ch>{6,}).*(?<=.{10})\k<match>.*
/
gm
Positive Lookahead
(?=.{20})
Assert that the Regex below matches
.
matches any character (except for line terminators)
{20} matches the previous token exactly 20 times
.
matches any character (except for line terminators)
*? matches the previous token between zero and unlimited times, as few times as possible, expanding as needed (lazy)
Positive Lookahead
(?=(?<ch>[@#$^]))
Assert that the Regex below matches
Named Capture Group ch
(?<ch>[@#$^])
Match a single character present in the list below
[@#$^]
@#$^
matches a single character in the list @#$^ (case sensitive)
Named Capture Group match
(?<match>\k<ch>{6,})
\k<ch>
matches the same text as most recently matched by the capturing group named ch
{6,} matches the previous token between 6 and unlimited times, as many times as possible, giving back as needed (greedy)
.
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)
Positive Lookbehind
(?<=.{10})
Assert that the Regex below matches
.
matches any character (except for line terminators)
{10} matches the previous token exactly 10 times
\k<match> matches the same text as most recently matched by the capturing group named 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)
Global pattern flags
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)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
gm

Test String