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
/
(^nvsm)(\-)(apis|dshm|cli)(\-|\_)(\d{2}|\(\d{2}\))(\.)(0?[1-9]|1[012])(\.|\-)(\d{1}|\d{2})(\-|\_|\.)(\d{1}|\d{2}|all|el\d{1})(\.)(el\d{1}|(deb)|(noarch))(|(\.)((x86_64)|(rpm))(\.)(rpm))$
/
gim
1st Capturing Group
(^nvsm)
^ asserts position at start of a line
nvsm
matches the characters nvsm literally (case insensitive)
2nd Capturing Group
(\-)
\- matches the character - with index 4510 (2D16 or 558) literally (case insensitive)
3rd Capturing Group
(apis|dshm|cli)
1st Alternative
apis
apis
matches the characters apis literally (case insensitive)
2nd Alternative
dshm
dshm
matches the characters dshm literally (case insensitive)
3rd Alternative
cli
cli
matches the characters cli literally (case insensitive)
4th Capturing Group
(\-|\_)
1st Alternative
\-
\- matches the character - with index 4510 (2D16 or 558) literally (case insensitive)
2nd Alternative
\_
\_ matches the character _ with index 9510 (5F16 or 1378) literally (case insensitive)
5th Capturing Group
(\d{2}|\(\d{2}\))
1st Alternative
\d{2}
\d
matches a digit (equivalent to [0-9])
{2} matches the previous token exactly 2 times
2nd Alternative
\(\d{2}\)
\( matches the character ( with index 4010 (2816 or 508) literally (case insensitive)
\d
matches a digit (equivalent to [0-9])
{2} matches the previous token exactly 2 times
\) matches the character ) with index 4110 (2916 or 518) literally (case insensitive)
6th Capturing Group
(\.)
\. matches the character . with index 4610 (2E16 or 568) literally (case insensitive)
7th Capturing Group
(0?[1-9]|1[012])
1st Alternative
0?[1-9]
0
matches the character 0 with index 4810 (3016 or 608) literally (case insensitive)
Match a single character present in the list below
[1-9]
1-9 matches a single character in the range between 1 (index 49) and 9 (index 57) (case insensitive)
2nd Alternative
1[012]
1 matches the character 1 with index 4910 (3116 or 618) literally (case insensitive)
Match a single character present in the list below
[012]
012
matches a single character in the list 012 (case insensitive)
8th Capturing Group
(\.|\-)
1st Alternative
\.
\. matches the character . with index 4610 (2E16 or 568) literally (case insensitive)
2nd Alternative
\-
\- matches the character - with index 4510 (2D16 or 558) literally (case insensitive)
9th Capturing Group
(\d{1}|\d{2})
1st Alternative
\d{1}
\d
matches a digit (equivalent to [0-9])
{1} matches the previous token exactly one time (meaningless quantifier)
2nd Alternative
\d{2}
\d
matches a digit (equivalent to [0-9])
{2} matches the previous token exactly 2 times
10th Capturing Group
(\-|\_|\.)
1st Alternative
\-
\- matches the character - with index 4510 (2D16 or 558) literally (case insensitive)
2nd Alternative
\_
\_ matches the character _ with index 9510 (5F16 or 1378) literally (case insensitive)
3rd Alternative
\.
11th Capturing Group
(\d{1}|\d{2}|all|el\d{1})
1st Alternative
\d{1}
\d
matches a digit (equivalent to [0-9])
{1} matches the previous token exactly one time (meaningless quantifier)
2nd Alternative
\d{2}
3rd Alternative
all
4th Alternative
el\d{1}
12th Capturing Group
(\.)
13th Capturing Group
(el\d{1}|(deb)|(noarch))
16th Capturing Group
(|(\.)((x86_64)|(rpm))(\.)(rpm))
$ asserts position at the end of a line
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])
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

/
/
gim

Test String

Substitution

Processing...