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
"
(((http|https):\/\/)?www\.)?yuque\.com\/([a-zA-Z\=]*)\/([a-zA-Z]*)\/([a-zA-Z]*)\/?
"
gm
1st Capturing Group
(((http|https):\/\/)?www\.)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
2nd Capturing Group
((http|https):\/\/)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
3rd Capturing Group
(http|https)
1st Alternative
http
http
matches the characters http literally (case sensitive)
2nd 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)
www
matches the characters www literally (case sensitive)
\. matches the character . with index 4610 (2E16 or 568) literally (case sensitive)
yuque
matches the characters yuque literally (case sensitive)
\. matches the character . with index 4610 (2E16 or 568) literally (case sensitive)
com
matches the characters com literally (case sensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
4th Capturing Group
([a-zA-Z\=]*)
Match a single character present in the list below
[a-zA-Z\=]
* 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 97) and z (index 122) (case sensitive)
A-Z matches a single character in the range between A (index 65) and Z (index 90) (case sensitive)
\= matches the character = with index 6110 (3D16 or 758) literally (case sensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
5th Capturing Group
([a-zA-Z]*)
Match a single character present in the list below
[a-zA-Z]
* 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 97) and z (index 122) (case sensitive)
A-Z matches a single character in the range between A (index 65) and Z (index 90) (case sensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
6th Capturing Group
([a-zA-Z]*)
Match a single character present in the list below
[a-zA-Z]
* 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 97) and z (index 122) (case sensitive)
A-Z matches a single character in the range between A (index 65) and Z (index 90) (case sensitive)
\/
matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
? matches the previous token between zero and one 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.

Regular Expression
No Match

"
"
gm

Test String