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

/
/
gm

Test String

Code Generator

Generated Code

$re = '/(?<=\'\),\')(.*)(?=\',)/m'; $str = 'DECODE(TRUE, IN(LTRIM(RTRIM(deposit_account_type__)),\'410\'),\'Brokered\', IN(LTRIM(RTRIM(deposit_account_type__)),\'411\'),\'CDS Listing Service\', IN(LTRIM(RTRIM(deposit_account_type__)),\'408\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'412\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'418\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'424\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'436\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'448\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'460\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'472\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'484\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'496\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'497\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'708\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'712\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'718\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'724\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'736\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'748\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'760\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'772\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'784\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'796\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'797\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'400\'),\'Public Funds CD\', IN(LTRIM(RTRIM(deposit_account_type__)),\'700\'),\'Public Funds CD\', IN(LTRIM(RTRIM(deposit_account_type__)),\'407\'),\'Short Term - Less than 1 Year\', IN(LTRIM(RTRIM(deposit_account_type__)),\'432\'),\'Short Term - Less than 1 Year\', IN(LTRIM(RTRIM(deposit_account_type__)),\'482\'),\'Short Term - Less than 1 Year\', IN(LTRIM(RTRIM(deposit_account_type__)),\'491\'),\'Short Term - Less than 1 Year\', IN(LTRIM(RTRIM(deposit_account_type__)),\'707\'),\'Short Term - Less than 1 Year\', IN(LTRIM(RTRIM(deposit_account_type__)),\'732\'),\'Short Term - Less than 1 Year\', IN(LTRIM(RTRIM(deposit_account_type__)),\'782\'),\'Short Term - Less than 1 Year\', IN(LTRIM(RTRIM(deposit_account_type__)),\'791\'),\'Short Term - Less than 1 Year\', IN(LTRIM(RTRIM(deposit_account_type__)),\'100\'),\'Checking\', IN(LTRIM(RTRIM(deposit_account_type__)),\'101\'),\'Checking\', IN(LTRIM(RTRIM(deposit_account_type__)),\'102\'),\'Checking\', IN(LTRIM(RTRIM(deposit_account_type__)),\'110\'),\'Checking\', IN(LTRIM(RTRIM(deposit_account_type__)),\'111\'),\'Checking\', IN(LTRIM(RTRIM(deposit_account_type__)),\'115\'),\'Checking\', IN(LTRIM(RTRIM(deposit_account_type__)),\'125\'),\'Checking\', IN(LTRIM(RTRIM(deposit_account_type__)),\'127\'),\'Checking\', IN(LTRIM(RTRIM(deposit_account_type__)),\'130\'),\'Checking\', IN(LTRIM(RTRIM(deposit_account_type__)),\'149\'),\'Checking\', IN(LTRIM(RTRIM(deposit_account_type__)),\'150\'),\'Checking\', IN(LTRIM(RTRIM(deposit_account_type__)),\'151\'),\'Checking\', IN(LTRIM(RTRIM(deposit_account_type__)),\'314\'),\'Checking\', IN(LTRIM(RTRIM(deposit_account_type__)),\'320\'),\'Checking\', IN(LTRIM(RTRIM(deposit_account_type__)),\'345\'),\'Checking\', IN(LTRIM(RTRIM(deposit_account_type__)),\'380\'),\'Checking\', IN(LTRIM(RTRIM(deposit_account_type__)),\'381\'),\'Checking\', IN(LTRIM(RTRIM(deposit_account_type__)),\'382\'),\'Checking\', IN(LTRIM(RTRIM(deposit_account_type__)),\'386\'),\'Checking\', IN(LTRIM(RTRIM(deposit_account_type__)),\'387\'),\'Checking\', IN(LTRIM(RTRIM(deposit_account_type__)),\'330\'),\'HSA\', IN(LTRIM(RTRIM(deposit_account_type__)),\'331\'),\'HSA\', IN(LTRIM(RTRIM(deposit_account_type__)),\'161\'),\'Money Management\', IN(LTRIM(RTRIM(deposit_account_type__)),\'351\'),\'Money Management\', IN(LTRIM(RTRIM(deposit_account_type__)),\'375\'),\'Portfolio Investment\', IN(LTRIM(RTRIM(deposit_account_type__)),\'376\'),\'Portfolio Investment\', IN(LTRIM(RTRIM(deposit_account_type__)),\'377\'),\'Portfolio Investment\', IN(LTRIM(RTRIM(deposit_account_type__)),\'385\'),\'Portfolio Investment\', IN(LTRIM(RTRIM(deposit_account_type__)),\'303\'),\'Sweep LOC\', IN(LTRIM(RTRIM(deposit_account_type__)),\'841\'),\'Sweep LOC\', IN(LTRIM(RTRIM(deposit_account_type__)),\'842\'),\'Sweep LOC\', IN(LTRIM(RTRIM(deposit_account_type__)),\'843\'),\'Sweep LOC\', IN(LTRIM(RTRIM(deposit_account_type__)),\'508\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'510\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'512\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'518\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'524\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'536\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'540\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'548\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'560\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'572\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'584\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'596\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'597\'),\'Long Term - 1 Year or More\', IN(LTRIM(RTRIM(deposit_account_type__)),\'599\'),\'Savings\', IN(LTRIM(RTRIM(deposit_account_type__)),\'503\'),\'Short Term - Less than 1 Year\', IN(LTRIM(RTRIM(deposit_account_type__)),\'507\'),\'Short Term - Less than 1 Year\', IN(LTRIM(RTRIM(deposit_account_type__)),\'532\'),\'Short Term - Less than 1 Year\', IN(LTRIM(RTRIM(deposit_account_type__)),\'582\'),\'Short Term - Less than 1 Year\', IN(LTRIM(RTRIM(deposit_account_type__)),\'851\'),\'Holiday\', IN(LTRIM(RTRIM(deposit_account_type__)),\'820\'),\'Savings\', IN(LTRIM(RTRIM(deposit_account_type__)),\'825\'),\'Savings\', IN(LTRIM(RTRIM(deposit_account_type__)),\'830\'),\'Savings\', IN(LTRIM(RTRIM(deposit_account_type__)),\'845\'),\'Savings\', IN(LTRIM(RTRIM(deposit_account_type__)),\'887\'),\'Savings\' )'; 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