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
/
([\w+\s]+)\s([\d]+)(%|\w+)\s(\w+)\s(\w+)\sx\s(\d)\/(\d+)
/
1st Capturing Group
([\w+\s]+)
Match a single character present in the list below
[\w+\s]
+ 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 4310 (2B16 or 538) literally (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
2nd Capturing Group
([\d]+)
Match a single character present in the list below
[\d]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
\d matches a digit (equivalent to [0-9])
3rd Capturing Group
(%|\w+)
1st Alternative
%
% matches the character % with index 3710 (2516 or 458) literally (case sensitive)
2nd Alternative
\w+
\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)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
4th Capturing Group
(\w+)
\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)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
5th Capturing Group
(\w+)
\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)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
x matches the character x with index 12010 (7816 or 1708) literally (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
6th Capturing Group
(\d)
\d matches a digit (equivalent to [0-9])
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
7th 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)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/

Test String