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
/
(((ftp|http|https):\/\/)|(\/)|(..\/))(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?
/
1st Capturing Group
(((ftp|http|https):\/\/)|(\/)|(..\/))
1st Alternative
((ftp|http|https):\/\/)
2nd Capturing Group
((ftp|http|https):\/\/)
3rd Capturing Group
(ftp|http|https)
1st Alternative
ftp
ftp
matches the characters ftp literally (case sensitive)
2nd Alternative
http
http
matches the characters http literally (case sensitive)
3rd Alternative
https
https
matches the characters https 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 Alternative
(\/)
4th Capturing Group
(\/)
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
3rd Alternative
(..\/)
5th Capturing Group
(..\/)
. matches any character (except for line terminators)
. matches any character (except for line terminators)
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
6th Capturing Group
(\w+:{0,1}\w*@)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
\w
matches any word character (equivalent to [a-zA-Z0-9_])
+ matches the previous token between one 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)
\w
matches any word character (equivalent to [a-zA-Z0-9_])
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
@ matches the character @ with index 6410 (4016 or 1008) literally (case sensitive)
7th Capturing Group
(\S+)
\S
matches any non-whitespace character (equivalent to [^\r\n\t\f\v ])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
8th Capturing Group
(:[0-9]+)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
: matches the character : with index 5810 (3A16 or 728) literally (case sensitive)
Match a single character present in the list below
[0-9]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
9th Capturing Group
(\/|\/([\w#!:.?+=&%@!\-\/]))?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
1st Alternative
\/
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
2nd Alternative
\/([\w#!:.?+=&%@!\-\/])
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
10th Capturing Group
([\w#!:.?+=&%@!\-\/])
Match a single character present in the list below
[\w#!:.?+=&%@!\-\/]
\w matches any word character (equivalent to [a-zA-Z0-9_])
#!:.?+=&%@!
matches a single character in the list #!:.?+=&%@ (case sensitive)
\- matches the character - with index 4510 (2D16 or 558) literally (case sensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/

Test String