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
"
(((s)|(svc))((-)|(_)).+)|((.+)((-)|(_))(svc))|(((.+)(svc))|((svc)(.+)))
"
gi
1st Alternative
(((s)|(svc))((-)|(_)).+)
1st Capturing Group
(((s)|(svc))((-)|(_)).+)
2nd Capturing Group
((s)|(svc))
1st Alternative
(s)
3rd Capturing Group
(s)
s matches the character s with index 11510 (7316 or 1638) literally (case insensitive)
2nd Alternative
(svc)
4th Capturing Group
(svc)
svc
matches the characters svc literally (case insensitive)
5th Capturing Group
((-)|(_))
1st Alternative
(-)
6th Capturing Group
(-)
- matches the character - with index 4510 (2D16 or 558) literally (case insensitive)
2nd Alternative
(_)
7th Capturing Group
(_)
_ matches the character _ with index 9510 (5F16 or 1378) literally (case insensitive)
.
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)
2nd Alternative
((.+)((-)|(_))(svc))
8th Capturing Group
((.+)((-)|(_))(svc))
9th 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)
10th Capturing Group
((-)|(_))
1st Alternative
(-)
11th Capturing Group
(-)
- matches the character - with index 4510 (2D16 or 558) literally (case insensitive)
2nd Alternative
(_)
12th Capturing Group
(_)
_ matches the character _ with index 9510 (5F16 or 1378) literally (case insensitive)
13th Capturing Group
(svc)
svc
matches the characters svc literally (case insensitive)
3rd Alternative
(((.+)(svc))|((svc)(.+)))
14th Capturing Group
(((.+)(svc))|((svc)(.+)))
1st Alternative
((.+)(svc))
15th Capturing Group
((.+)(svc))
16th 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)
17th Capturing Group
(svc)
svc
matches the characters svc literally (case insensitive)
2nd Alternative
((svc)(.+))
18th Capturing Group
((svc)(.+))
19th Capturing Group
(svc)
svc
matches the characters svc literally (case insensitive)
20th 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)
Global pattern flags
g modifier: global. All matches (don't return after first match)
i modifier: insensitive. Case insensitive match (ignores case of [a-zA-Z])
Your regular expression does not match the subject string.

Regular Expression
No Match

r"
"
gi

Test String