Regular Expressions 101

Save & Share

  • Regex Version: ver. 3
  • 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
  • Match everything enclosed
    (?:...)
  • Capture everything enclosed
    (...)
  • 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

~
~

Test String

Substitution

Processing...

Code Generator

Generated Code

$re = '~Description[":\s<>\w=\\\\/]+CCGname[\s/a-z><]+([^<]+)[^"]+~'; $str = '{"type":"Feature","properties":{"Name":"08N","Description":"<br><br><br> <table border=\\"1\\" padding=\\"0\\"> <tr><td>CCGcode</td><td>08N</td></tr> <tr><td>CCGname</td><td>NHS Redbridge CCG</td></tr>"},"geometry":{"type":"Polygon","coordinates":[[[0.14896,51.601453,0],[0.1487,51.60727,0],[0.144726,51.616172,0],[0.144576,51.616468,0],[0.138182,51.623491,0],[0.129186,51.621389,0],[0.118667,51.615313,0],[0.114471,51.615926,0],[0.107282,51.613289,0],[0.100166,51.612671,0],[0.098062,51.615374,0],[0.09281,51.613655,0],[0.094665,51.610689,0],[0.091952,51.607065,0],[0.085886,51.605288,0],[0.083188,51.606425,0],[0.068642,51.605758,0],[0.068573,51.605779,0],[0.062995,51.606858,0],[0.062562,51.607016,0],[0.061543,51.607665,0],[0.052329,51.612079,0],[0.052106,51.612166,0],[0.04831,51.614554,0],[0.053707,51.618227,0],[0.040794,51.615688,0],[0.039577,51.616725,0],[0.034493,51.620567,0],[0.034249,51.620775,0],[0.021816,51.62878,0],[0.020044,51.626434,0],[0.018658,51.622998,0],[0.015475,51.620796,0],[0.008802,51.619029,0],[0.021393,51.611666,0],[0.019263,51.608177,0],[0.01854,51.60683,0],[0.018296,51.606472,0],[0.017423,51.605255,0],[0.015483,51.602617,0],[0.014933,51.601848,0],[0.012846,51.598658,0],[0.012437,51.595268,0],[0.01226,51.594269,0],[0.012218,51.594057,0],[0.01284,51.587659,0],[0.014888,51.583343,0],[0.016797,51.578794,0],[0.016475,51.573045,0],[0.016482,51.572833,0],[0.018922,51.572198,0],[0.01898,51.571466,0],[0.018496,51.568069,0],[0.014295,51.563709,0],[0.014356,51.560768,0],[0.014478,51.56034,0],[0.018112,51.558081,0],[0.018202,51.558003,0],[0.020362,51.556213,0],[0.025282,51.555495,0],[0.025777,51.554068,0],[0.032014,51.554517,0],[0.035356,51.555269,0],[0.041798,51.555012,0],[0.046161,51.554783,0],[0.043865,51.557503,0],[0.041952,51.561399,0],[0.05034,51.563936,0],[0.052577,51.561661,0],[0.060001,51.556461,0],[0.065049,51.556295,0],[0.068196,51.550261,0],[0.068266,51.549918,0],[0.068346,51.549539,0],[0.06835,51.544361,0],[0.069738,51.544009,0],[0.071481,51.543587,0],[0.076412,51.54436,0],[0.076419,51.544363,0],[0.076824,51.544536,0],[0.077548,51.544479,0],[0.077636,51.54435,0],[0.077791,51.544156,0],[0.077971,51.544035,0],[0.080132,51.544741,0],[0.080257,51.544776,0],[0.08073,51.544909,0],[0.085037,51.546829,0],[0.088512,51.547651,0],[0.092542,51.549338,0],[0.094681,51.54621,0],[0.102005,51.549089,0],[0.10472,51.549942,0],[0.106206,51.550904,0],[0.107419,51.551864,0],[0.113425,51.554242,0],[0.113188,51.556836,0],[0.116231,51.556944,0],[0.120513,51.558488,0],[0.118615,51.560739,0],[0.119075,51.561413,0],[0.124812,51.564121,0],[0.128563,51.566335,0],[0.129387,51.566476,0],[0.129761,51.567862,0],[0.129702,51.568048,0],[0.13005,51.570703,0],[0.130813,51.571675,0],[0.129443,51.573928,0],[0.1294,51.574867,0],[0.131636,51.57708,0],[0.132943,51.580857,0],[0.127664,51.581585,0],[0.127675,51.581655,0],[0.126423,51.586652,0],[0.131038,51.587454,0],[0.133198,51.591721,0],[0.1348,51.592503,0],[0.141925,51.596527,0],[0.148162,51.598996,0],[0.14896,51.601453,0]]]}}'; $subst = "Description\":\"$1"; $result = preg_replace($re, $subst, $str, 1); 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