Regular Expressions 101

Save & Manage Regex

  • Current Version: 1
  • Save & Share
  • Community Library

Flavor

  • PCRE2 (PHP)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java
  • .NET 7.0 (C#)
  • Rust
  • PCRE (Legacy)
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests
Sponsors
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
Processing...

Test String

Code Generator

Generated Code

$re = '/[:,\{\}\[\]]|(\".*?\")|(\'.*?\')|[-\w.]+/'; $str = '{ "data": [{ "type": "articles", "id": "1", "attributes": { "title": "JSON:API paints my bikeshed!", "body": "The shortest article. Ever.", "created": "2015-05-22T14:56:29.000Z", "updated": "2015-05-22T14:56:28.000Z" }, relationships: { "author": { "data": {"id": "42", "type": "people"} } } }], "included": [ { type:"people", "id": "42",[ {"_id":"5ed938e30c7c9da56314f8fa","index":0,"guid":"213e226c-9381-4cc6-b5a1-9e4f923d536c","isActive":false,"balance":"$3,156.65","picture":"http://placehold.it/32x32","age":34,"eyeColor":"brown","name":"Kirby Finch","gender":"male","company": "APPLICA","email": "kirbyfinch@applica.com","phone": "+1 (985) 465-2331","address": "663 Devon Avenue, Bergoo, Kansas, 2699","about": "Eu cillum consequat voluptate qui id aliquip ea laboris amet. Est proident nostrud esse laboris consequat exercitation incididunt. Non sunt proident nulla sint fugiat et mollit aliqua do aliqua. Veniam enim consectetur pariatur tempor. Occaecat deserunt excepteur laborum eu qui nostrud nostrud incididunt. Fugiat duis aute velit nisi nisi officia dolor cillum velit culpa ut ut aute adipisicing.\\r\\n","registered": "2018-02-25T05:47:05 +05:00","latitude": 23.301723,"longitude": -7.387813, "tags": ["duis","sit","consequat","ad","est","eiusmod","cupidatat"], "friends": [ { "id": 0, "name": "Cassie Holder" }, { "id": 1, "name": "Hopkins Rose" }, { "id": 2, "name": "Shelley Joyce" } ], "greeting": "Hello, Kirby Finch! You have 5 unread messages.", "favoriteFruit": "strawberry" }, { \'_id\': "5ed938e3df744b96379bf4f8", "index": 1, "guid": "4c119ce6-1be4-43a3-a3f0-b8f8ca20142b", "isActive": true, "balance": "$3,015.87", "picture": "http://placehold.it/32x32", "age": 25, "eyeColor": "blue", "name": "Long Green", "gender": "male", "company": "DANCITY", "email": "longgreen@dancity.com", "phone": "+1 (965) 415-2855", "address": "243 Kenilworth Place, Vienna, Washington, 5603", "about": "Cupidatat quis minim occaecat cupidatat ad cupidatat eiusmod qui ipsum ullamco voluptate. Nostrud eu ipsum deserunt commodo et fugiat. Ad nisi tempor in proident deserunt nisi quis aute ipsum irure quis in in. Anim ullamco adipisicing cupidatat consectetur cillum ad velit et labore cupidatat sit qui nulla minim. Laborum id voluptate adipisicing ipsum nostrud eiusmod ullamco commodo velit dolore. Duis ea qui sint labore est occaecat Lorem ipsum elit cillum.\\r\\n", "registered": "2016-08-15T06:03:55 +04:00", "latitude": 47.719282, "longitude": -104.954384, "tags": [ "cupidatat", "aute", "dolor", "irure", "eiusmod", "mollit", "officia" ],"friends": [ { "id": 0, "name": "Alejandra Harvey" }, { "id": 1, "name": "Melton Rivas" }, { "id": 2, "name": "Kim Johns" } ], "greeting": "Hello, Long Green! You have 1 unread messages.", "favoriteFruit": "apple" }, { "_id": "5ed938e3f49e7acf5df7b95f", "index": 2, "guid": "d450c6f9-2929-403b-acf9-6d62f7fa9a07", "isActive": false, "balance": "$2,388.30", "picture": "http://placehold.it/32x32", "age": 37, "eyeColor": "green", "name": "Albert Potts", "gender": "male", "company": "EVENTEX", "email": "albertpotts@eventex.com", "phone": "+1 (937) 447-2599", "address": "378 Pleasant Place, Blandburg, Georgia, 5578", "about": "Nisi laboris consectetur id veniam culpa Lorem nostrud laboris dolore. Cupidatat cillum amet aute culpa sint magna. Dolore consectetur dolore mollit nisi adipisicing est.\\r\\n", "registered": "2020-03-24T07:44:42 +04:00", "latitude": -14.513435, "longitude": -123.695167, "tags": [ "ea", "est", "veniam", "duis", "enim", "aute", "non" ], "friends": [ { "id": 0, "name": "Phoebe Salazar" }, { "id": 1, "name": "Yolanda Obrien" }, { "id": 2, "name": "Dixon Wilcox" } ], "greeting": "Hello, Albert Potts! You have 3 unread messages.", "favoriteFruit": "banana" }, { "_id": "5ed938e3ec19b3221fcfb511", "index": 3, "guid": "cf47552c-ace2-49bd-90ea-5820637cbdb6", "isActive": false, "balance": "$3,984.74", "picture": "http://placehold.it/32x32", "age": 26, "eyeColor": "green", "name": "Edwina Ortega", "gender": "female", "company": "AVIT", "email": "edwinaortega@avit.com", "phone": "+1 (938) 588-3070", "address": "562 Columbus Place, Aberdeen, Wisconsin, 2989", "about": "Do voluptate proident minim deserunt sunt laborum. Nostrud ex elit incididunt pariatur culpa laborum minim quis commodo nulla cupidatat quis. Voluptate exercitation sunt sunt non pariatur et consequat sunt est qui irure aute laboris consequat. Ea et deserunt nisi id. Mollit sunt ea consequat in laboris aliqua nulla non cillum amet voluptate eiusmod. Anim dolore excepteur quis est adipisicing est veniam. Nisi veniam eu ut reprehenderit occaecat esse.\\r\\n", "registered": "2015-07-31T12:54:32 +04:00", "latitude": -41.374574, "longitude": 11.512296, "tags": [\'irure\',\'consequat\',\'laborum\',\'aliqua\',\'fugiat\',\'labore\',\'cillum\'], "friends": [ { "id": 0, "name": "Crawford Lawrence" }, { "id": 1, "name": "Boyle Parks" }, { "id": 2, "name": "Burnett Clements", } ], "greeting": "Hello, Edwina Ortega! You have 1 unread messages.", "favoriteFruit": "strawberry" }, { "_id": "5ed938e335f3a258ea7aff9a", "index": 4, "guid": "cba6d9c0-e09f-4993-85f8-458b0ba5a263", "isActive": true, "balance": "$3,255.93", "picture": "http://placehold.it/32x32", \'age\': 24, "eyeColor": "green", "name": "Valarie Shepard", "gender": "female", "company": "EZENTIA", "email": "valarieshepard@ezentia.com", "phone": "+1 (972) 567-3819", "address": "879 Thatford Avenue, Denio, Montana, 8330", "about": "Esse do voluptate mollit ea ipsum. Irure veniam mollit veniam et laborum do ad labore minim cillum culpa enim laborum esse. Veniam esse laboris in excepteur commodo aliqua consequat do ad incididunt pariatur culpa. Cupidatat incididunt veniam quis ad pariatur. Non dolor commodo laborum eu anim aliqua mollit.\\r\\n", "registered": "2014-04-22T04:51:01 +04:00", "latitude": 81.190646, "longitude": -138.871271, "tags": [ "Lorem", "laboris", "commodo", "laboris", "eiusmod", "reprehenderit", "est" ], "friends": [ { "id": 0, "name": "Knowles Clay" }, { "id": 1, "name": "Rowena Mcneil" }, { "id": 2, "name": "Henrietta Estrada" } ], "greeting": "Hello, Valarie Shepard! You have 10 unread messages.", "favoriteFruit": "strawberry" } ] "attributes": { "name": "John", "age": 80, "gender": "male" color : null } } ] }'; 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