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
/
^(Entre\ssemana|El\sfin\sde\ssemana)\s([A-Z][a-z]+?)\s([A-Z][a-z]+?)\s([A-Z][a-z]+?)\s([A-Z][a-z]+?)\sse\sacuesta\sa\slas\s([0-9]{2}\:[0-9]{2}\s)(am|pm)\sy\sse\slevanta\sa\slas\s([0-9]{2}\:[0-9]{2}\s)(am|pm).*$
/
gm
^ asserts position at start of a line
1st Capturing Group
(Entre\ssemana|El\sfin\sde\ssemana)
1st Alternative
Entre\ssemana
Entre
matches the characters Entre literally (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
semana
matches the characters semana literally (case sensitive)
2nd Alternative
El\sfin\sde\ssemana
El
matches the characters El literally (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
fin
matches the characters fin literally (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
de
matches the characters de literally (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
semana
matches the characters semana literally (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
2nd Capturing Group
([A-Z][a-z]+?)
Match a single character present in the list below
[A-Z]
A-Z matches a single character in the range between A (index 65) and Z (index 90) (case sensitive)
Match a single character present in the list below
[a-z]
+? matches the previous token between one and unlimited times, as few times as possible, expanding as needed (lazy)
a-z matches a single character in the range between a (index 97) and z (index 122) (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
3rd Capturing Group
([A-Z][a-z]+?)
Match a single character present in the list below
[A-Z]
A-Z matches a single character in the range between A (index 65) and Z (index 90) (case sensitive)
Match a single character present in the list below
[a-z]
+? matches the previous token between one and unlimited times, as few times as possible, expanding as needed (lazy)
a-z matches a single character in the range between a (index 97) and z (index 122) (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
4th Capturing Group
([A-Z][a-z]+?)
Match a single character present in the list below
[A-Z]
A-Z matches a single character in the range between A (index 65) and Z (index 90) (case sensitive)
Match a single character present in the list below
[a-z]
+? matches the previous token between one and unlimited times, as few times as possible, expanding as needed (lazy)
a-z matches a single character in the range between a (index 97) and z (index 122) (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
5th Capturing Group
([A-Z][a-z]+?)
Match a single character present in the list below
[A-Z]
A-Z matches a single character in the range between A (index 65) and Z (index 90) (case sensitive)
Match a single character present in the list below
[a-z]
+? matches the previous token between one and unlimited times, as few times as possible, expanding as needed (lazy)
a-z matches a single character in the range between a (index 97) and z (index 122) (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
se
matches the characters se literally (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
acuesta
matches the characters acuesta literally (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
a matches the character a with index 9710 (6116 or 1418) literally (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
las
matches the characters las literally (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
6th Capturing Group
([0-9]{2}\:[0-9]{2}\s)
Match a single character present in the list below
[0-9]
{2} matches the previous token exactly 2 times
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
\: matches the character : with index 5810 (3A16 or 728) literally (case sensitive)
Match a single character present in the list below
[0-9]
{2} matches the previous token exactly 2 times
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
7th Capturing Group
(am|pm)
1st Alternative
am
am
matches the characters am literally (case sensitive)
2nd Alternative
pm
pm
matches the characters pm literally (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
y matches the character y with index 12110 (7916 or 1718) literally (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
se
matches the characters se literally (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
levanta
matches the characters levanta literally (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
a matches the character a with index 9710 (6116 or 1418) literally (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
las
matches the characters las literally (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
8th Capturing Group
([0-9]{2}\:[0-9]{2}\s)
9th Capturing Group
(am|pm)
.
matches any character (except for line terminators)
$ asserts position at the end of a line
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