Regular Expressions 101

Save & Manage Regex

  • Current Version: 1
  • Save & Share
  • Community Library

Flavor

  • PCRE2 (PHP)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java
  • .NET 7.0 (C#)
  • Rust
  • PCRE (Legacy)
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests
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
Processing...

Test String

Code Generator

Generated Code

$re = '/EXP.*\n(?P<data1>[0-9]+)\n(?P<data2>[0-9]+)\n(?P<data3>[0-9]+)\n(?P<gname>[A-z_0-9]+)\n(?P<gcode>[A-Z]+)\n(?P<gvers>[0-9]+)\n(?P<app_desc>[A-z0-9 ]+)\n(?P<run_desc>[A-z0-9 ]+)\n(?P<last_mod>[A-z0-9: ]+)\n(?P<data4>.*)\n(?P<parent>.*\.(?:APP|app))\n(?P<script>.*\.(?:APP|app))\n(?P<app_type>[A-Z]+)\n(?P<app_vpr>.*\.(?:VPR|vpr))\n/m'; $str = '&PROJFIL EXP0 3 0Node File {CATALOG_DIR}\\99_temp\\initial_nodes.dbf EXP1 1 0Matrix File 1 {CATALOG_DIR}\\99_temp\\Y{year}_initial_skims.mat EXP1 220Network File {CATALOG_DIR}\\99_temp\\initial_highway_loaded.net EXP2 1 0Network File {CATALOG_DIR}\\99_temp\\checked_pt_network.net EXP2 7 0NTLegs File {SCENARIO_DIR}\\Y{year}_{NetName}_nt_legs.ntl EXP2 130Route File 1 {CATALOG_DIR}\\99_temp\\initial_PT_skims.rte EXP2 230Matrix File 1 {CATALOG_DIR}\\\\99_temp\\initial_PT_costs.mat EXP3 1 0Network File {SCENARIO_DIR}\\Y{year}_unloaded_network.net EXP5 210Record File 1 {CATALOG_DIR}\\99_temp\\vc_factors.dbf EXP5 220Record File 2 {CATALOG_DIR}\\99_temp\\sector_factors.dbf EXP6 1 0Matrix File 1 {SCENARIO_DIR}\\Y{year}_{FareScen}_RFARES.mat EXP7 4 0Print Data 1 {SCENARIO_DIR}\\Y{YEAR}_initial_network_costs_summary.dat 11 0 0 Network_Builder NB 00 Network Builder Building The Network Thu Sep 04 20:35:34 2025 D:\\Projects\\20240510_Manila_STM\\Manila_STM\\Manila00.app D:\\PROJECTS\\20240510_MANILA_STM\\MANILA_STM\\10_NETWORK_BUILDER\\NETWOR00.APP VOYAGER D:\\Projects\\20240510_Manila_STM\\Manila_STM\\DEFAULT.VPR 1 Network Building 29,-8,0,0,Calibri,48,700,0,0,5066061 2 TODO: - Add Nodes and Centroids and Centroid Connectors (can be dummy initially) - DONE - Add capability of adding Schemes - DONE - Build Test Highway Assignment for unit Matrix - DONE - check unconnected zones - DONE - Build PT Files (Factors, line, NT Legs, etc) - Working Now, but nee d to renumber the network... - Perform initial Skims for first assignment - DONE 2441,-1563,0,0,Calibri,14,400,0,0,255 &End_TextAnnotation {ZoneVersion,ComboList-CHARACTER,"Zone Version for TAZ","BASE", ,"BASE","250506"} {Network Schemes,EditBox-CHARACTER,"Network Schemes","schemes_v0.csv"} '; 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