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
"
\[ \[SmokeDetector\]\(https://github\.com/Charcoal-SE/SmokeDetector\) \] (.+): \[(.+)\]\(//[\w\.]+.com/(questions|answers|q|a)/(\d+)\) by \[(.+)\]\(//[\w.]+/users/(\d+)/[\w+-]+\) on `(.+)`
"
\[ matches the character [ with index 9110 (5B16 or 1338) literally (case sensitive)
matches the character with index 3210 (2016 or 408) literally (case sensitive)
\[ matches the character [ with index 9110 (5B16 or 1338) literally (case sensitive)
SmokeDetector
matches the characters SmokeDetector literally (case sensitive)
\] matches the character ] with index 9310 (5D16 or 1358) literally (case sensitive)
\( matches the character ( with index 4010 (2816 or 508) literally (case sensitive)
https://github
matches the characters https://github literally (case sensitive)
\. matches the character . with index 4610 (2E16 or 568) literally (case sensitive)
com/Charcoal-SE/SmokeDetector
matches the characters com/Charcoal-SE/SmokeDetector literally (case sensitive)
\) matches the character ) with index 4110 (2916 or 518) literally (case sensitive)
matches the character with index 3210 (2016 or 408) literally (case sensitive)
\] matches the character ] with index 9310 (5D16 or 1358) literally (case sensitive)
matches the character with index 3210 (2016 or 408) literally (case sensitive)
1st Capturing Group
(.+)
.
matches any character (except for line terminators)
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
:
matches the characters : literally (case sensitive)
\[ matches the character [ with index 9110 (5B16 or 1338) literally (case sensitive)
2nd Capturing Group
(.+)
.
matches any character (except for line terminators)
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
\] matches the character ] with index 9310 (5D16 or 1358) literally (case sensitive)
\( matches the character ( with index 4010 (2816 or 508) literally (case sensitive)
//
matches the characters // literally (case sensitive)
Match a single character present in the list below
[\w\.]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
\w matches any word character (equivalent to [a-zA-Z0-9_])
\. matches the character . with index 4610 (2E16 or 568) literally (case sensitive)
. matches any character (except for line terminators)
com/
matches the characters com/ literally (case sensitive)
3rd Capturing Group
(questions|answers|q|a)
1st Alternative
questions
questions
matches the characters questions literally (case sensitive)
2nd Alternative
answers
answers
matches the characters answers literally (case sensitive)
3rd Alternative
q
4th Alternative
a
/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
4th Capturing Group
(\d+)
\d
matches a digit (equivalent to [0-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 4110 (2916 or 518) literally (case sensitive)
by
matches the characters by literally (case sensitive)
\[ matches the character [ with index 9110 (5B16 or 1338) literally (case sensitive)
5th Capturing Group
(.+)
\] matches the character ] with index 9310 (5D16 or 1358) literally (case sensitive)
\( matches the character ( with index 4010 (2816 or 508) literally (case sensitive)
//
matches the characters // literally (case sensitive)
Match a single character present in the list below
[\w.]
/users/
matches the characters /users/ literally (case sensitive)
6th Capturing Group
(\d+)
/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
Match a single character present in the list below
[\w+-]
\) matches the character ) with index 4110 (2916 or 518) literally (case sensitive)
on `
matches the characters on ` literally (case sensitive)
7th Capturing Group
(.+)
` matches the character ` with index 9610 (6016 or 1408) literally (case sensitive)
Your regular expression does not match the subject string.

Regular Expression
No Match

r"
"

Test String