Regular Expressions 101

Save & Share

  • Regex Version: ver. 10
  • 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

/
/
g

Test String

Substitution

Processing...

Code Generator

Generated Code

$re = '/(\d),(\d)(?!(([^"]+"){2})*[^"]+$)/'; $str = '1,Hershey\'s,10268,1305178,Reese_Core_THC_FY_Brand_Campaign_2023,video,in-app,Mobile In-App Video,3,RELATED_PINS,"32,860",98.40%,0,0,0.00%,0,0.00%,0,0.00%,0,0.00%,533,1.60%,1.60%,"32,860","33,393",0.70%,"4,710,648",99.30%,"4,744,041","4,744,041" 2,Hipp GmbH & Co. Vertrieb KG,16800,1546599,ES151635_HiPP_FoMi Flight 2 2023_CPCV,video,in-app,Mobile In-App Video,3,RELATED_PINS,"29,758",98.12%,0,0,0.00%,0,0.00%,0,0.00%,0,0.00%,569,1.88%,1.88%,"29,758","30,327",3.08%,"954,365",96.92%,"984,692","984,692" 3,Kimberly Clark,3751,1554555,KK_KHW_226_KOT_RCH-ST_Q3 23_HWL_P2DNXD0_P18-39_OFH,video,in-app,Mobile In-App Video,3,RELATED_PINS,"24,727",98.28%,0,0,0.00%,0,0.00%,0,0.00%,0,0.00%,433,1.72%,1.72%,"24,727","25,160",0.64%,"3,898,750",99.36%,"3,923,910","3,923,910" 4,Kimberly Clark,3751,1554527,KK_CFT _303_HUG_RCH_Q3 23_CFT _P2DNR3G_AB_EST,display,in-app,Mobile App,3,RELATED_PINS,"23,963",98.78%,0,0,0.00%,0,0.00%,0,0.00%,0,0.00%,295,1.22%,1.22%,"23,963","24,258",0.57%,"4,229,318",99.43%,"4,253,576","4,253,576" 5,Kimberly Clark,3751,1554527,KK_CFT _303_HUG_RCH_Q3 23_CFT _P2DNR3G_AB_EST,display,in-app,Mobile In-App,3,RELATED_PINS,"23,963",98.78%,0,0,0.00%,0,0.00%,0,0.00%,0,0.00%,295,1.22%,1.22%,"23,963","24,258",0.57%,"4,229,318",99.43%,"4,253,576","4,253,576" 6,Bayer Vital GmbH,17072,1268855,2023_03_DE_Lefax-Intens_Consumer_Tactical_Social_Intens_PO2151230403,video,in-app,Mobile In-App Video,3,RELATED_PINS,"21,697",98.23%,0,0,0.00%,0,0.00%,0,0.00%,0,0.00%,390,1.77%,1.77%,"21,697","22,087",3.88%,"547,359",96.12%,"569,446","569,446" 7,Ferrero DE (FERRERO MSC GmbH & Co. KG),13924,1531938,DE_W25_W28_FY23_IYO_DigitalVideoI_AWE_CI~69374_Aktion-Pinterest-IYO-TIII-FY2223-DigitalVideo-StandardVideo_Awareness_Auction,video,in-app,Mobile In-App Video,5,HOME_FEED,"20,938",98.13%,0,0,0.00%,0,0.00%,0,0.00%,0,0.00%,400,1.87%,1.87%,"20,938","21,338",2.22%,"940,902",97.78%,"962,240","962,240" 8,Pernod Ricard UK,8897,1556116,BRE_FLIP_Summer24_W1_07-22_views_soc_product-launch_pin_GBR_omnet_x_x,display,in-app,Mobile App,3,RELATED_PINS,"19,536",98.16%,0,0,0.00%,0,0.00%,0,0.00%,0,0.00%,366,1.84%,1.84%,"19,536","19,902",1.50%,"1,305,872",98.50%,"1,325,774","1,325,774" 9,Pernod Ricard UK,8897,1556116,BRE_FLIP_Summer24_W1_07-22_views_soc_product-launch_pin_GBR_omnet_x_x,display,in-app,Mobile In-App,3,RELATED_PINS,"19,536",98.16%,0,0,0.00%,0,0.00%,0,0.00%,0,0.00%,366,1.84%,1.84%,"19,536","19,902",1.50%,"1,305,872",98.50%,"1,325,774","1,325,774"'; $subst = "$1$2"; $result = preg_replace($re, $subst, $str); echo "The result of the substitution is ".$result;

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