Regular Expressions 101

Save & Share

  • Save Regex
    ctrl+s
  • Update Regex
    ctrl+⇧+s

Flavor

  • PCRE2 (PHP >=7.3)
  • PCRE (PHP <7.3)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java 8

Function

  • Match
  • Substitution
  • List
  • Unit Tests
/
(MacBook(10|9)|MacBookAir(10|[7-9])|Macmini[7-9]|MacPro[6-7]|iMacPro1|iMac(1[6-9]|2[0-2])),\d|MacBookPro1(1,[45]|[2-8],\d)
/
gm
1st Alternative
(MacBook(10|9)|MacBookAir(10|[7-9])|Macmini[7-9]|MacPro[6-7]|iMacPro1|iMac(1[6-9]|2[0-2])),\d
1st Capturing Group
(MacBook(10|9)|MacBookAir(10|[7-9])|Macmini[7-9]|MacPro[6-7]|iMacPro1|iMac(1[6-9]|2[0-2]))
1st Alternative
MacBook(10|9)
MacBook
matches the characters MacBook literally (case sensitive)
2nd Capturing Group
(10|9)
1st Alternative
10
10
matches the characters 10 literally (case sensitive)
2nd Alternative
9
9 matches the character 9 with index 5710 (3916 or 718) literally (case sensitive)
2nd Alternative
MacBookAir(10|[7-9])
MacBookAir
matches the characters MacBookAir literally (case sensitive)
3rd Capturing Group
(10|[7-9])
1st Alternative
10
10
matches the characters 10 literally (case sensitive)
2nd Alternative
[7-9]
Match a single character present in the list below
[7-9]
7-9 matches a single character in the range between 7 (index 55) and 9 (index 57) (case sensitive)
3rd Alternative
Macmini[7-9]
Macmini
matches the characters Macmini literally (case sensitive)
Match a single character present in the list below
[7-9]
7-9 matches a single character in the range between 7 (index 55) and 9 (index 57) (case sensitive)
4th Alternative
MacPro[6-7]
MacPro
matches the characters MacPro literally (case sensitive)
Match a single character present in the list below
[6-7]
6-7 matches a single character in the range between 6 (index 54) and 7 (index 55) (case sensitive)
5th Alternative
iMacPro1
iMacPro1
matches the characters iMacPro1 literally (case sensitive)
6th Alternative
iMac(1[6-9]|2[0-2])
iMac
matches the characters iMac literally (case sensitive)
4th Capturing Group
(1[6-9]|2[0-2])
1st Alternative
1[6-9]
1 matches the character 1 with index 4910 (3116 or 618) literally (case sensitive)
Match a single character present in the list below
[6-9]
6-9 matches a single character in the range between 6 (index 54) and 9 (index 57) (case sensitive)
2nd Alternative
2[0-2]
2 matches the character 2 with index 5010 (3216 or 628) literally (case sensitive)
Match a single character present in the list below
[0-2]
0-2 matches a single character in the range between 0 (index 48) and 2 (index 50) (case sensitive)
, matches the character , with index 4410 (2C16 or 548) literally (case sensitive)
\d matches a digit (equivalent to [0-9])
2nd Alternative
MacBookPro1(1,[45]|[2-8],\d)
MacBookPro1
matches the characters MacBookPro1 literally (case sensitive)
5th Capturing Group
(1,[45]|[2-8],\d)
1st Alternative
1,[45]
1,
matches the characters 1, literally (case sensitive)
Match a single character present in the list below
[45]
45
matches a single character in the list 45 (case sensitive)
2nd Alternative
[2-8],\d
Match a single character present in the list below
[2-8]
2-8 matches a single character in the range between 2 (index 50) and 8 (index 56) (case sensitive)
, matches the character , with index 4410 (2C16 or 548) literally (case sensitive)
\d matches a digit (equivalent to [0-9])
Global pattern flags
g modifier: global. All matches (don't return after first match)
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

/
/
gm

Test String