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
/
[ꦲꦤꦕꦫꦏꦢꦠꦱꦮꦭꦥꦝꦗꦪꦚꦩꦒꦧꦛꦔꦐꦌꦡꦈꦆꦎꦦꦄꦯꦣꦓꦘꦑꦞꦜꦰꦬꦖꦋꦨꦟꦍꦅꦇꦉꦝꦛꦊ][ꦲꦤꦕꦫꦏꦢꦠꦱꦮꦭꦥꦝꦗꦪꦚꦩꦒꦧꦛꦔꦐꦌꦡꦈꦆꦎꦦꦄꦯꦣꦓꦘꦑꦞꦜꦰꦬꦖꦋꦨꦟꦍꦅꦇꦉꦝꦛꦊ].*?(?=[ꦲꦤꦕꦫꦏꦢꦠꦱꦮꦭꦥꦝꦗꦪꦚꦩꦒꦧꦛꦔꦐꦌꦡꦈꦆꦎꦦꦄꦯꦣꦓꦘꦑꦞꦜꦰꦬꦖꦋꦨꦟꦍꦅꦇꦉꦝꦛꦊ]|[A-Za-z0-9~`!@#$%^&*()\-_+={}\[\]\\|:;"'<,>.?\/\s]|$)|[ꦲꦤꦕꦫꦏꦢꦠꦱꦮꦭꦥꦝꦗꦪꦚꦩꦒꦧꦛꦔꦐꦌꦡꦈꦆꦎꦦꦄꦯꦣꦓꦘꦑꦞꦜꦰꦬꦖꦋꦨꦟꦍꦅꦇꦉꦝꦛꦊ].*?(?=[ꦲꦤꦕꦫꦏꦢꦠꦱꦮꦭꦥꦝꦗꦪꦚꦩꦒꦧꦛꦔꦐꦌꦡꦈꦆꦎꦦꦄꦯꦣꦓꦘꦑꦞꦜꦰꦬꦖꦋꦨꦟꦍꦅꦇꦉꦝꦛꦊ]|[A-Za-z0-9~`!@#$%^&*()\-_+={}\[\]\\|:;"'<,>.?\/\s]|$)
/
g
1st Alternative
[ꦲꦤꦕꦫꦏꦢꦠꦱꦮꦭꦥꦝꦗꦪꦚꦩꦒꦧꦛꦔꦐꦌꦡꦈꦆꦎꦦꦄꦯꦣꦓꦘꦑꦞꦜꦰꦬꦖꦋꦨꦟꦍꦅꦇꦉꦝꦛꦊ][ꦲꦤꦕꦫꦏꦢꦠꦱꦮꦭꦥꦝꦗꦪꦚꦩꦒꦧꦛꦔꦐꦌꦡꦈꦆꦎꦦꦄꦯꦣꦓꦘꦑꦞꦜꦰꦬꦖꦋꦨꦟꦍꦅꦇꦉꦝꦛꦊ].*?(?=[ꦲꦤꦕꦫꦏꦢꦠꦱꦮꦭꦥꦝꦗꦪꦚꦩꦒꦧꦛꦔꦐꦌꦡꦈꦆꦎꦦꦄꦯꦣꦓꦘꦑꦞꦜꦰꦬꦖꦋꦨꦟꦍꦅꦇꦉꦝꦛꦊ]|[A-Za-z0-9~`!@#$%^&*()\-_+={}\[\]\\|:;"'<,>.?\/\s]|$)
Match a single character present in the list below
[ꦲꦤꦕꦫꦏꦢꦠꦱꦮꦭꦥꦝꦗꦪꦚꦩꦒꦧꦛꦔꦐꦌꦡꦈꦆꦎꦦꦄꦯꦣꦓꦘꦑꦞꦜꦰꦬꦖꦋꦨꦟꦍꦅꦇꦉꦝꦛꦊ]
ꦲꦤꦕꦫꦏꦢꦠꦱꦮꦭꦥꦝꦗꦪꦚꦩꦒꦧꦛꦔꦐꦌꦡꦈꦆꦎꦦꦄꦯꦣꦓꦘꦑꦞꦜꦰꦬꦖꦋꦨꦟꦍꦅꦇꦉꦝꦛꦊ
matches a single character in the list ꦲꦤꦕꦫꦏꦢꦠꦱꦮꦭꦥꦝꦗꦪꦚꦩꦒꦧꦛꦔꦐꦌꦡꦈꦆꦎꦦꦄꦯꦣꦓꦘꦑꦞꦜꦰꦬꦖꦋꦨꦟꦍꦅꦇꦉꦊ (case sensitive)
matches the character with index 4345610 (A9C016 or 1247008) literally (case sensitive)
Match a single character present in the list below
[ꦲꦤꦕꦫꦏꦢꦠꦱꦮꦭꦥꦝꦗꦪꦚꦩꦒꦧꦛꦔꦐꦌꦡꦈꦆꦎꦦꦄꦯꦣꦓꦘꦑꦞꦜꦰꦬꦖꦋꦨꦟꦍꦅꦇꦉꦝꦛꦊ]
ꦲꦤꦕꦫꦏꦢꦠꦱꦮꦭꦥꦝꦗꦪꦚꦩꦒꦧꦛꦔꦐꦌꦡꦈꦆꦎꦦꦄꦯꦣꦓꦘꦑꦞꦜꦰꦬꦖꦋꦨꦟꦍꦅꦇꦉꦝꦛꦊ
matches a single character in the list ꦲꦤꦕꦫꦏꦢꦠꦱꦮꦭꦥꦝꦗꦪꦚꦩꦒꦧꦛꦔꦐꦌꦡꦈꦆꦎꦦꦄꦯꦣꦓꦘꦑꦞꦜꦰꦬꦖꦋꦨꦟꦍꦅꦇꦉꦊ (case sensitive)
.
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
(?=[ꦲꦤꦕꦫꦏꦢꦠꦱꦮꦭꦥꦝꦗꦪꦚꦩꦒꦧꦛꦔꦐꦌꦡꦈꦆꦎꦦꦄꦯꦣꦓꦘꦑꦞꦜꦰꦬꦖꦋꦨꦟꦍꦅꦇꦉꦝꦛꦊ]|[A-Za-z0-9~`!@#$%^&*()\-_+={}\[\]\\|:;"'<,>.?\/\s]|$)
Assert that the Regex below matches
1st Alternative
[ꦲꦤꦕꦫꦏꦢꦠꦱꦮꦭꦥꦝꦗꦪꦚꦩꦒꦧꦛꦔꦐꦌꦡꦈꦆꦎꦦꦄꦯꦣꦓꦘꦑꦞꦜꦰꦬꦖꦋꦨꦟꦍꦅꦇꦉꦝꦛꦊ]
Match a single character present in the list below
[ꦲꦤꦕꦫꦏꦢꦠꦱꦮꦭꦥꦝꦗꦪꦚꦩꦒꦧꦛꦔꦐꦌꦡꦈꦆꦎꦦꦄꦯꦣꦓꦘꦑꦞꦜꦰꦬꦖꦋꦨꦟꦍꦅꦇꦉꦝꦛꦊ]
ꦲꦤꦕꦫꦏꦢꦠꦱꦮꦭꦥꦝꦗꦪꦚꦩꦒꦧꦛꦔꦐꦌꦡꦈꦆꦎꦦꦄꦯꦣꦓꦘꦑꦞꦜꦰꦬꦖꦋꦨꦟꦍꦅꦇꦉꦝꦛꦊ
matches a single character in the list ꦲꦤꦕꦫꦏꦢꦠꦱꦮꦭꦥꦝꦗꦪꦚꦩꦒꦧꦛꦔꦐꦌꦡꦈꦆꦎꦦꦄꦯꦣꦓꦘꦑꦞꦜꦰꦬꦖꦋꦨꦟꦍꦅꦇꦉꦊ (case sensitive)
2nd Alternative
[A-Za-z0-9~`!@#$%^&*()\-_+={}\[\]\\|:;"'<,>.?\/\s]
Match a single character present in the list below
[A-Za-z0-9~`!@#$%^&*()\-_+={}\[\]\\|:;"'<,>.?\/\s]
A-Z matches a single character in the range between A (index 65) and Z (index 90) (case sensitive)
a-z matches a single character in the range between a (index 97) and z (index 122) (case sensitive)
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
~`!@#$%^&*()
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 9110 (5B16 or 1338) literally (case sensitive)
\] matches the character ] with index 9310 (5D16 or 1358) literally (case sensitive)
\\ matches the character \ with index 9210 (5C16 or 1348) literally (case sensitive)
|:;"'<,>.?
matches a single character in the list |:;"'<,>.? (case sensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
3rd Alternative
$
$ asserts position at the end of the string, or before the line terminator right at the end of the string (if any)
2nd Alternative
[ꦲꦤꦕꦫꦏꦢꦠꦱꦮꦭꦥꦝꦗꦪꦚꦩꦒꦧꦛꦔꦐꦌꦡꦈꦆꦎꦦꦄꦯꦣꦓꦘꦑꦞꦜꦰꦬꦖꦋꦨꦟꦍꦅꦇꦉꦝꦛꦊ].*?(?=[ꦲꦤꦕꦫꦏꦢꦠꦱꦮꦭꦥꦝꦗꦪꦚꦩꦒꦧꦛꦔꦐꦌꦡꦈꦆꦎꦦꦄꦯꦣꦓꦘꦑꦞꦜꦰꦬꦖꦋꦨꦟꦍꦅꦇꦉꦝꦛꦊ]|[A-Za-z0-9~`!@#$%^&*()\-_+={}\[\]\\|:;"'<,>.?\/\s]|$)
Match a single character present in the list below
[ꦲꦤꦕꦫꦏꦢꦠꦱꦮꦭꦥꦝꦗꦪꦚꦩꦒꦧꦛꦔꦐꦌꦡꦈꦆꦎꦦꦄꦯꦣꦓꦘꦑꦞꦜꦰꦬꦖꦋꦨꦟꦍꦅꦇꦉꦝꦛꦊ]
ꦲꦤꦕꦫꦏꦢꦠꦱꦮꦭꦥꦝꦗꦪꦚꦩꦒꦧꦛꦔꦐꦌꦡꦈꦆꦎꦦꦄꦯꦣꦓꦘꦑꦞꦜꦰꦬꦖꦋꦨꦟꦍꦅꦇꦉꦝꦛꦊ
matches a single character in the list ꦲꦤꦕꦫꦏꦢꦠꦱꦮꦭꦥꦝꦗꦪꦚꦩꦒꦧꦛꦔꦐꦌꦡꦈꦆꦎꦦꦄꦯꦣꦓꦘꦑꦞꦜꦰꦬꦖꦋꦨꦟꦍꦅꦇꦉꦊ (case sensitive)
.
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
(?=[ꦲꦤꦕꦫꦏꦢꦠꦱꦮꦭꦥꦝꦗꦪꦚꦩꦒꦧꦛꦔꦐꦌꦡꦈꦆꦎꦦꦄꦯꦣꦓꦘꦑꦞꦜꦰꦬꦖꦋꦨꦟꦍꦅꦇꦉꦝꦛꦊ]|[A-Za-z0-9~`!@#$%^&*()\-_+={}\[\]\\|:;"'<,>.?\/\s]|$)
Assert that the Regex below matches
1st Alternative
[ꦲꦤꦕꦫꦏꦢꦠꦱꦮꦭꦥꦝꦗꦪꦚꦩꦒꦧꦛꦔꦐꦌꦡꦈꦆꦎꦦꦄꦯꦣꦓꦘꦑꦞꦜꦰꦬꦖꦋꦨꦟꦍꦅꦇꦉꦝꦛꦊ]
Match a single character present in the list below
[ꦲꦤꦕꦫꦏꦢꦠꦱꦮꦭꦥꦝꦗꦪꦚꦩꦒꦧꦛꦔꦐꦌꦡꦈꦆꦎꦦꦄꦯꦣꦓꦘꦑꦞꦜꦰꦬꦖꦋꦨꦟꦍꦅꦇꦉꦝꦛꦊ]
ꦲꦤꦕꦫꦏꦢꦠꦱꦮꦭꦥꦝꦗꦪꦚꦩꦒꦧꦛꦔꦐꦌꦡꦈꦆꦎꦦꦄꦯꦣꦓꦘꦑꦞꦜꦰꦬꦖꦋꦨꦟꦍꦅꦇꦉꦝꦛꦊ
matches a single character in the list ꦲꦤꦕꦫꦏꦢꦠꦱꦮꦭꦥꦝꦗꦪꦚꦩꦒꦧꦛꦔꦐꦌꦡꦈꦆꦎꦦꦄꦯꦣꦓꦘꦑꦞꦜꦰꦬꦖꦋꦨꦟꦍꦅꦇꦉꦊ (case sensitive)
2nd Alternative
[A-Za-z0-9~`!@#$%^&*()\-_+={}\[\]\\|:;"'<,>.?\/\s]
Match a single character present in the list below
[A-Za-z0-9~`!@#$%^&*()\-_+={}\[\]\\|:;"'<,>.?\/\s]
A-Z matches a single character in the range between A (index 65) and Z (index 90) (case sensitive)
a-z matches a single character in the range between a (index 97) and z (index 122) (case sensitive)
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
~`!@#$%^&*()
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 9110 (5B16 or 1338) literally (case sensitive)
\] matches the character ] with index 9310 (5D16 or 1358) literally (case sensitive)
\\ matches the character \ with index 9210 (5C16 or 1348) literally (case sensitive)
|:;"'<,>.?
matches a single character in the list |:;"'<,>.? (case sensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
3rd Alternative
$
$ asserts position at the end of the string, or before the line terminator right at the end of the string (if any)
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