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
/
(^https?:\/\/)((www)?)(\.)([\da-z\.-]{2,62})(\.)([a-z]{2,24})$
/
1st Capturing Group
(^https?:\/\/)
^ asserts position at start of the string
http
matches the characters http literally (case sensitive)
s
matches the character s with index 11510 (7316 or 1638) literally (case sensitive)
: matches the character : with index 5810 (3A16 or 728) literally (case sensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
2nd Capturing Group
((www)?)
3rd Capturing Group
(www)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
www
matches the characters www literally (case sensitive)
4th Capturing Group
(\.)
\. matches the character . with index 4610 (2E16 or 568) literally (case sensitive)
5th Capturing Group
([\da-z\.-]{2,62})
Match a single character present in the list below
[\da-z\.-]
{2,62} matches the previous token between 2 and 62 times, as many times as possible, giving back as needed (greedy)
\d matches a digit (equivalent to [0-9])
a-z matches a single character in the range between a (index 97) and z (index 122) (case sensitive)
\. matches the character . with index 4610 (2E16 or 568) literally (case sensitive)
- matches the character - with index 4510 (2D16 or 558) literally (case sensitive)
6th Capturing Group
(\.)
\. matches the character . with index 4610 (2E16 or 568) literally (case sensitive)
7th Capturing Group
([a-z]{2,24})
Match a single character present in the list below
[a-z]
{2,24} matches the previous token between 2 and 24 times, as many times as possible, giving back as needed (greedy)
a-z matches a single character in the range between a (index 97) and z (index 122) (case sensitive)
$ asserts position at the end of the string, or before the line terminator right at the end of the string (if any)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/

Test String