Regular Expressions 101

Save & Share

  • Regex Version: ver. 1
  • Update Regex
    ctrl+⇧+s
  • Save new Regex
    ctrl+s
  • Add to Community Library

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

Tools

Sponsors
There are currently no sponsors. Become a sponsor today!
An explanation of your regex will be automatically generated as you type.
Detailed match information will be displayed here automatically.
  • 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 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]
  • 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
  • Non-capturing group
    (?:...)
  • Capturing group
    (...)
  • 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

/
/
mg

Test String

Code Generator

Generated Code

$re = '/(^\d+)\s*(.*)(VC\d+)\s+(.*)([\s\S]*?)(A\+B\)\s+(\$\d{1,3}(,\d{3})*(\.\d+)?))/m'; $str = '1, 3, 4, 7 1 A) $11,644,939.00 VC0000007181 S.T. RHOADES CONSTRUCTION, INC. Phone (530)223-9322 B) 210 Days * 10000 8585 COMMERCIAL WAY CSLB# 00930684 A+B) $13,744,939.00 REDDING CA 96002 2 A) $12,561,053.00 VC0000007021 GR SUNDBERG, INC. Phone (707)825-6565 B) 210 Days * 10000 5211 BOYD ROAD CSLB# 00732695 A+B) $14,661,053.00 ARCATA CA 95521 Fax (707)825-6563 3 A) $13,098,288.00 VC1800001127 CALIFORNIA HIGHWAY CONSTRUCTION GROUP, Phone (925)766-7014 INC. B) 210 Days * 10000 1647 WILLOW PASS ROAD CSLB# 01027700 A+B) $15,198,288.00 CONCORD CA 94520 Fax (925)265-9101 4 A) $13,661,954.26 VC0000003985 MERCER FRASER COMPANY Phone (707)443-6371 B) 210 Days * 10000 200 DINSMORE DR CSLB# 00105709 A+B) $15,761,954.26 FORTUNA CA 95540 Fax (707)443-0277 Bid Opening Date: 11/15/2022 Page 2 Contract Number: 01-0H20U4 11/15/2022 5 A) $15,396,278.00 VC0000000213 GRANITE CONSTRUCTION COMPANY Phone (831)728-7561 B) 210 Days * 10000 585 W BEACH STREET CSLB# 00000089 A+B) $17,496,278.00 WATSONVILLE CA 95076 Bid Opening Date: 11/15/2022 Page 3 Contract Number: 01-0H20U4 11/15/2022 '; preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0); // Print the entire match result var_dump($matches);

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 PHP, please visit: http://php.net/manual/en/ref.pcre.php