Regular Expressions 101

Save & Share

Flavor

  • PCRE2 (PHP >=7.3)
  • PCRE (PHP <7.3)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java 8
  • .NET 7.0 (C#)
  • Rust
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests (32)

Tools

Sponsors
There are currently no sponsors. Become a sponsor today!
An explanation of your regex will be automatically generated as you type.
  • All Tokens
  • Common Tokens
  • General Tokens
  • Anchors
  • Meta Sequences
  • Quantifiers
  • Group Constructs
  • Character Classes
  • Flags/Modifiers
  • Substitution
  • A single character of: a, b or c
    [abc]
  • A single character of: a, b, c or d
    [[ab][cd]]
  • A character except: a, b or c
    [^abc]
  • A character in the range: a-z
    [a-z]
  • A character not in the range: a-z
    [^a-z]
  • A character in the range: a-z or A-Z
    [a-zA-Z]
  • Character class intersection
    [\w&&[^\d]]
  • Any single character
    .
  • Alternate - match either a or b
    a|b
  • Any whitespace character
    \s
  • Any non-whitespace character
    \S
  • Any digit
    \d
  • Any non-digit
    \D
  • Any word character
    \w
  • Any non-word character
    \W
  • Match everything enclosed
    (?:...)
  • Capture everything enclosed
    (...)
  • Zero or one of a
    a?
  • Zero or more of a
    a*
  • One or more of a
    a+
  • Exactly 3 of a
    a{3}
  • 3 or more of a
    a{3,}
  • Between 3 and 6 of a
    a{3,6}
  • Start of string
    ^
  • End of string
    $
  • A word boundary
    \b
  • Non-word boundary
    \B

Regular Expression

"
"
g

Unit Tests

Illegal multiple day-of-week fields using #
Illegal non-? specification of both day-of-week and day-of-month
Illegal ? specification of both day-of-week and day-of-month
Illegal numbered last day for day-of-month
Illegal bare weekday wildcard for day-of-month
Illegal out of order weekday / last day wildcards for day-of-month
Illegal combination of last day and instance wildcards in day-of-week
Illegal combination of last day and instance wildcards in numbered day-of-week
Illegal combination of last day and instance wildcards in named day-of-week
Illegal combination of any and instance wildcards in day-of-week
Every 5 minutes
Every hour
Every seven days
10:15 AM (UTC+0) every day
8:00 AM (UTC+0) on the first day of the month
9:00 AM (UTC+0) on the first Monday of each month
3:10 PM (UTC+0) on Sunday of each month
Every 3 months at 12am on 1st of month
Midnight (UTC+0) on last weekday of month
6:00 PM (UTC+0) Monday through Friday
Every 10 min on weekdays
Every 5 minutes between 8:00 AM (UTC+0) and 5:55 PM (UTC+0) weekdays
Midnight (UTC+0) on last day of week, every week
Midnight (UTC+0) on last Sunday of month
Midnight (UTC+0) on last NAMED Sunday of month
9:00 AM (UTC+0) on the first NAMED Monday of each month
Midnight (UTC+) on the last day of month, January through August
First minute of every hour between 11am and 4pm on last day of month
Midnight (UTC+0) on last day of June, from 2020 to 2040
Midnight (UTC+0) every Sunday, Tuesday and Thursday
Midnight (UTC+0) on first day of every month, every 3 years starting from 2020
Midnight (UTC+0) on first day of month, January through March, silently ignoring increment of month