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

/
/
gmD

Test String

Substitution

Processing...

Code Generator

Generated Code

$re = '/([0-9a-z_]+\()(.*)(\);)/mD'; $str = 'x_42951_y_20871_z_16_l_phj_tm_0_28_1_0_1_3_3_0_2018_08_31_17_00({"data":{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_135873305:495920","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[253,219],[269,219],[269,235],[253,235],[253,219]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.942494,54.728433]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_162032352:650834","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[226,232],[242,232],[242,248],[226,248],[226,232]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.941914,54.728271]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_56986799:69042","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[252,181],[268,181],[268,197],[252,197],[252,181]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.942479,54.728907]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_407789202:3749044","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[3,-14],[19,-14],[19,2],[3,2],[3,-14]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.937134,54.731335]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_127125543:2960252","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[17,39],[33,39],[33,55],[17,55],[17,39]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.93743,54.730676]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_114573906:914652","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[152,107],[168,107],[168,123],[152,123],[152,107]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.940333,54.729833]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_407789202:3893830","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[227,128],[243,128],[243,144],[227,144],[227,128]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.941943,54.729564]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_407789202:3784273","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[109,179],[125,179],[125,195],[109,195],[109,179]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.939411,54.728931]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_135873305:495769","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[75,65],[91,65],[91,81],[75,81],[75,65]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.938676,54.730347]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_135873305:495758","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[-15,-11],[1,-11],[1,5],[-15,5],[-15,-11]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.936745,54.731297]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_135873305:495759","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[-10,22],[6,22],[6,38],[-10,38],[-10,22]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.936863,54.730887]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_135873305:495771","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[117,77],[133,77],[133,93],[117,93],[117,77]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.939588,54.730198]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_407789202:3786340","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[210,124],[226,124],[226,140],[210,140],[210,124]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.94157,54.729618]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_407789202:3863250","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[219,17],[235,17],[235,33],[219,33],[219,17]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.941774,54.730943]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_135873305:495882","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[149,129],[165,129],[165,145],[149,145],[149,129]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.940262,54.72955]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_407789202:3901984","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[1,118],[17,118],[17,134],[1,134],[1,118]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.937102,54.729697]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_407789202:3809142","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[56,126],[72,126],[72,142],[56,142],[56,126]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.938281,54.729597]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_407789202:3749208","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[92,0],[108,0],[108,16],[92,16],[92,0]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.939054,54.731161]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_407789202:3749018","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[160,193],[176,193],[176,209],[160,209],[160,193]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.940506,54.728756]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_135873305:495984","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[227,205],[243,205],[243,221],[227,221],[227,205]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.941936,54.728613]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_100504911:279347","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[107,227],[123,227],[123,243],[107,243],[107,227]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.939377,54.728343]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_135873305:495879","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[249,28],[265,28],[265,44],[249,44],[249,28]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.942408,54.730811]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_135873305:495873","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[244,146],[260,146],[260,162],[244,162],[244,146]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.942301,54.729339]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_135873305:495916","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[195,196],[211,196],[211,212],[195,212],[195,196]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.941265,54.728719]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_256910444:20878","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[107,152],[123,152],[123,168],[107,168],[107,152]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.939372,54.729272]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_256910444:20909","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[133,48],[149,48],[149,64],[133,64],[133,48]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.939926,54.730554]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_256910444:20891","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[118,108],[134,108],[134,124],[118,124],[118,108]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.939602,54.729821]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_256910444:20728","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[33,63],[49,63],[49,79],[33,79],[33,63]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.937783,54.730373]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_100504911:278356","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[127,156],[143,156],[143,172],[127,172],[127,156]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.93979,54.729221]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_256910444:20845","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[89,213],[105,213],[105,229],[89,229],[89,213]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.938979,54.728515]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_256910444:20918","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[141,19],[157,19],[157,35],[141,35],[141,19]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.940105,54.730922]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_256910444:20827","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[80,242],[96,242],[96,258],[80,258],[80,242]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.938799,54.728147]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_135873305:495906","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[187,113],[203,113],[203,129],[187,129],[187,113]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.941083,54.729749]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_407789202:3749044","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[-12,-29],[34,-29],[34,17],[-12,17],[-12,-29]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.937134,54.731335]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_114573906:914652","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[137,92],[183,92],[183,138],[137,138],[137,92]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.940333,54.729833]}},{"type":"Feature","properties":{"HotspotMetaData":{"id":"img_256910444:20950","provider":"fotki","RenderedGeometry":{"type":"Polygon","coordinates":[[[142,-40],[188,-40],[188,6],[142,6],[142,-40]]]}},"name":"","description":""},"geometry":{"type":"Point","coordinates":[55.940432,54.731472]}}]}});'; $subst = "$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