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
"
((/[^/]+)?(/[0-9]+)?)?/14[0-9]{8}(\.(jar|pdf|htm|swf|xap))?
"
1st Capturing Group
((/[^/]+)?(/[0-9]+)?)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
2nd Capturing Group
(/[^/]+)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
Match a single character not present in the list below
[^/]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
3rd Capturing Group
(/[0-9]+)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
Match a single character present in the list below
[0-9]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
/14
matches the characters /14 literally (case sensitive)
Match a single character present in the list below
[0-9]
{8} matches the previous token exactly 8 times
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
4th Capturing Group
(\.(jar|pdf|htm|swf|xap))?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
\. matches the character . with index 4610 (2E16 or 568) literally (case sensitive)
5th Capturing Group
(jar|pdf|htm|swf|xap)
1st Alternative
jar
jar
matches the characters jar literally (case sensitive)
2nd Alternative
pdf
pdf
matches the characters pdf literally (case sensitive)
3rd Alternative
htm
htm
matches the characters htm literally (case sensitive)
4th Alternative
swf
swf
matches the characters swf literally (case sensitive)
5th Alternative
xap
xap
matches the characters xap literally (case sensitive)
Your regular expression does not match the subject string.

Regular Expression
No Match

r"
"

Test String

Code Generator

Generated Code

Loading code sample...
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report.
For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html