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

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

/
/
g

Test String

Code Generator

Generated Code

$re = '/"\w+"=.+?,(?=")/'; $str = '{"Ra03"=0,"Ra10"=0,"CellWom"=(0,0),"RaTableRaw"=(<00550060001d001e0025002c001f0023002200230028002b002f004a00a90119>,<0000005d001c001d0024002b001f00240023002400280029002e0046009700fb>,<00550060001d001e0024002b001f0022002100220027002a002d0048009b0103>),"Qstart"=0,"AdapterPower"=1091223498,"DailyMinSoc"=93,"Ra04"=0,"CurrentSenseMonitorStatus"=0,"Ra11"=0,"CellVoltage"=(4314,4313,4312),"PackCurrentAccumulator"=961564,"PassedCharge"=18446744073709551404,"Flags"=16777729,"PresentDOD"=(1,1,1),"Ra05"=0,"Ra12"=0,"FccComp1"=8690,"ChemID"=20784,"iMaxAndSocSmoothTable"=<0000000000000000000000000000000000000000000000000000000000000000>,"FccComp2"=8690,"PackCurrentAccumulatorCount"=45405,"DOD0"=(528,520,520),"Ra06"=0,"ResScale"=0,"Ra13"=0,"WeightedRa"=0,"FilteredCurrent"=0,"RSS"=0,"CellCurrentAccumulatorCount"=0,"Serial"="F5D21977VYGQ1LWB0","DataFlashWriteCount"=1764,"DailyMaxSoc"=100,"Ra07"=0,"Ra14"=0,"MaxCapacity"=100,"ChemicalWeightedRa"=0,"Ra00"=0,"BatteryHealthMetric"=0,"DesignCapacity"=8694,"Ra08"=0,"BatteryState"=<0000000000000000c3e4001206010002>,"CellCurrentAccumulator"=(0,0),"AlgoChemID"=20784,"MfgData"=<000000000b0001000a1400000431393136033030320341544c00090000000000>,"ManufactureDate"=62879213563955,"ISS"=0,"Ra01"=0,"Soc1Voltage"=0,"QmaxDisqualificationReason"=0,"ChargeAccum"=0,"SimRate"=0,"Qmax"=(9174,9189,9180),"PMUConfigured"=4624,"ITMiscStatus"=0,"StateOfCharge"=100,"Ra09"=0,"GaugeFlagRaw"=224,"CycleCount"=2,"Voltage"=12939,"SystemPower"=1091238263,"LifetimeData"={"Raw"=<016d9b49000028a10000000000000000016dc3ea0000c7e440120000000000000029000f10ed0de132c129ba24bce07e2d5fdafbe07edafb00ee0001a0280001>,"UpdateTime"=1676429353,"ResistanceUpdatedDisabledCount"=0,"CycleCountLastQmax"=0,"TimeAtHighSoc"=<00000000610000002600000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000067000000c10000000000000000000000000000000000000000000000171700003c01000002000000000000000000000000000000>,"TemperatureSamples"=106536,"TotalOperatingTime"=6658,"MaximumDischargeCurrent"=18446744073709543550,"MinimumPackVoltage"=10682,"MaximumPackVoltage"=12993,"MaximumChargeCurrent"=9404,"AverageTemperature"=18446744073709551598,"MinimumTemperature"=15,"RDISCnt"=0,"MaximumTemperature"=41},"Ra02"=0}'; 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