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
/
^[A-Za-z][A-Za-z0-9+\-.]:(?:\/\/(?:(?:[A-Za-z0-9\-._~!$&'()*+,;=:]|%[0-9A-Fa-f])*@)?(?:\[(?:(?:(?:(?:[0-9A-Fa-f]:){6}|::(?:[0-9A-Fa-f]:){5}|(?:[0-9A-Fa-f])?::(?:[0-9A-Fa-f]:){4}|(?:(?:[0-9A-Fa-f]:){0,1}[0-9A-Fa-f])?::(?:[0-9A-Fa-f]:){3}|(?:(?:[0-9A-Fa-f]:){0,2}[0-9A-Fa-f])?::(?:[0-9A-Fa-f]:){2}|(?:(?:[0-9A-Fa-f]:){0,3}[0-9A-Fa-f])?::[0-9A-Fa-f]:|(?:(?:[0-9A-Fa-f]:){0,4}[0-9A-Fa-f])?::)(?:[0-9A-Fa-f]:[0-9A-Fa-f]|(?:(?:25[0-5]|2[0-4][0-9]|[01][0-9][0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|[01][0-9][0-9]))|(?:(?:[0-9A-Fa-f]:){0,5}[0-9A-Fa-f])?::[0-9A-Fa-f]|(?:(?:[0-9A-Fa-f]:){0,6}[0-9A-Fa-f])?::)|[Vv][0-9A-Fa-f]\.[A-Za-z0-9\-._~!$&'()*+,;=:])\]|(?:(?:25[0-5]|2[0-4][0-9]|[01][0-9][0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|[01][0-9][0-9])|(?:[A-Za-z0-9\-._~!$&'()*+,;=]|%[0-9A-Fa-f])*)(?::[0-9])?(?:\/(?:[A-Za-z0-9\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f])*)*|\/(?:(?:[A-Za-z0-9\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f])+(?:\/(?:[A-Za-z0-9\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f])*)*)?|(?:[A-Za-z0-9\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f])+(?:\/(?:[A-Za-z0-9\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f])*)*|)(?:\?(?:[A-Za-z0-9\-._~!$&'()*+,;=:@\/?]|%[0-9A-Fa-f])*)?(?:\#(?:[A-Za-z0-9\-._~!$&'()*+,;=:@\/?]|%[0-9A-Fa-f])*)?$
/
^ asserts position at start of the string
Match a single character present in the list below
[A-Za-z]
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)
Match a single character present in the list below
[A-Za-z0-9+\-.]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
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 the character + literally (case sensitive)
\- matches the character - literally (case sensitive)
. matches the character . literally (case sensitive)
: matches the character : literally (case sensitive)
Non-capturing group
(?:\/\/(?:(?:[A-Za-z0-9\-._~!$&'()*+,;=:]|%[0-9A-Fa-f])*@)?(?:\[(?:(?:(?:(?:[0-9A-Fa-f]:){6}|::(?:[0-9A-Fa-f]:){5}|(?:[0-9A-Fa-f])?::(?:[0-9A-Fa-f]:){4}|(?:(?:[0-9A-Fa-f]:){0,1}[0-9A-Fa-f])?::(?:[0-9A-Fa-f]:){3}|(?:(?:[0-9A-Fa-f]:){0,2}[0-9A-Fa-f])?::(?:[0-9A-Fa-f]:){2}|(?:(?:[0-9A-Fa-f]:){0,3}[0-9A-Fa-f])?::[0-9A-Fa-f]:|(?:(?:[0-9A-Fa-f]:){0,4}[0-9A-Fa-f])?::)(?:[0-9A-Fa-f]:[0-9A-Fa-f]|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}(?:25[0-5]|2[0-4][0-9]|[01][0-9][0-9]))|(?:(?:[0-9A-Fa-f]:){0,5}[0-9A-Fa-f])?::[0-9A-Fa-f]|(?:(?:[0-9A-Fa-f]:){0,6}[0-9A-Fa-f])?::)|[Vv][0-9A-Fa-f]\.[A-Za-z0-9\-._~!$&'()*+,;=:])\]|(?:(?:25[0-5]|2[0-4][0-9]|[01][0-9][0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|[01][0-9][0-9])|(?:[A-Za-z0-9\-._~!$&'()*+,;=]|%[0-9A-Fa-f])*)(?::[0-9])?(?:\/(?:[A-Za-z0-9\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f])*)*
\/ matches the character / literally (case sensitive)
\/ matches the character / literally (case sensitive)
Non-capturing group
(?:(?:[A-Za-z0-9\-._~!$&'()*+,;=:]|%[0-9A-Fa-f])*@)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
Non-capturing group
(?:[A-Za-z0-9\-._~!$&'()*+,;=:]|%[0-9A-Fa-f])*
@ matches the character @ literally (case sensitive)
Non-capturing group
(?:\[(?:(?:(?:(?:[0-9A-Fa-f]:){6}|::(?:[0-9A-Fa-f]:){5}|(?:[0-9A-Fa-f])?::(?:[0-9A-Fa-f]:){4}|(?:(?:[0-9A-Fa-f]:){0,1}[0-9A-Fa-f])?::(?:[0-9A-Fa-f]:){3}|(?:(?:[0-9A-Fa-f]:){0,2}[0-9A-Fa-f])?::(?:[0-9A-Fa-f]:){2}|(?:(?:[0-9A-Fa-f]:){0,3}[0-9A-Fa-f])?::[0-9A-Fa-f]:|(?:(?:[0-9A-Fa-f]:){0,4}[0-9A-Fa-f])?::)(?:[0-9A-Fa-f]:[0-9A-Fa-f]|(?:(?:25[0-5]|2[0-4][0-9]|[01][0-9][0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|[01][0-9][0-9]))|(?:(?:[0-9A-Fa-f]:){0,5}[0-9A-Fa-f])?::[0-9A-Fa-f]|(?:(?:[0-9A-Fa-f]:){0,6}[0-9A-Fa-f])?::)|[Vv][0-9A-Fa-f]\.[A-Za-z0-9\-._~!$&'()*+,;=:])\]|(?:(?:25[0-5]|2[0-4][0-9]|[01][0-9][0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|[01][0-9][0-9])|(?:[A-Za-z0-9\-._~!$&'()*+,;=]|%[0-9A-Fa-f])*)
Non-capturing group
(?::[0-9])?
Non-capturing group
(?:\/(?:[A-Za-z0-9\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f])*)*
2nd Alternative
\/(?:(?:[A-Za-z0-9\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f])+(?:\/(?:[A-Za-z0-9\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f])*)*)?
\/ matches the character / literally (case sensitive)
Non-capturing group
(?:(?:[A-Za-z0-9\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f])+(?:\/(?:[A-Za-z0-9\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f])*)*)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
Non-capturing group
(?:[A-Za-z0-9\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f])+
Non-capturing group
(?:\/(?:[A-Za-z0-9\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f])*)*
3rd Alternative
(?:[A-Za-z0-9\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f])+(?:\/(?:[A-Za-z0-9\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f])*)*
Non-capturing group
(?:[A-Za-z0-9\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f])+
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
1st Alternative
[A-Za-z0-9\-._~!$&'()*+,;=:@]
2nd Alternative
%[0-9A-Fa-f]
Non-capturing group
(?:\/(?:[A-Za-z0-9\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f])*)*
4th Alternative null, matches any position
Non-capturing group
(?:\?(?:[A-Za-z0-9\-._~!$&'()*+,;=:@\/?]|%[0-9A-Fa-f])*)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
\? matches the character ? literally (case sensitive)
Non-capturing group
(?:[A-Za-z0-9\-._~!$&'()*+,;=:@\/?]|%[0-9A-Fa-f])*
Non-capturing group
(?:\#(?:[A-Za-z0-9\-._~!$&'()*+,;=:@\/?]|%[0-9A-Fa-f])*)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
\# matches the character # literally (case sensitive)
Non-capturing group
(?:[A-Za-z0-9\-._~!$&'()*+,;=:@\/?]|%[0-9A-Fa-f])*
$ asserts position at the end of the string
Your regular expression does not match the subject string.

Regular Expression
No Match

/
/

Test String