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

using System; using System.Text.RegularExpressions; public class Example { public static void Main() { string pattern = @"(?<property>[a-zA-Z_]+):"; string input = @"{ current: {""selling_band_id"":237579501,""set_price"":7.0,""download_pref"":2,""purchase_title"":null,""minimum_price_nonzero"":2.0,""mod_date"":""24 Jan 2020 17:15:16 GMT"",""about"":""January 20, 2020 saw the surprise release of David Lynch’s short ‘What did Jack Do?’ on Netflix. If you watched the grainy, police procedural over the last few days, you most likely found yourself saying aloud ‘who is Jack Cruz and how can I get more of his music?’ Now, just in time for the Grammys, Sacred Bones is announcing the release of the short’s featured original song ‘True Love’s Flame’ by the primate star crooner of yesteryear; Jack Cruz. Not much is known about Cruz’s career prior to his involvement with Lynch, but fortunately, we have not just one song, but two: ’Dancin’ in the World of Love’ is the B-side to the short’s single…uncovered recently and an excellent example of Cruz’s emotional prowess and magical, gold-dipped vocal cords. Both songs were written by Lynch and Dean Hurley and are available for pre-order in both black and clear vinyl 45s with artwork carefully crafted by Lynch himself."",""art_id"":3619351691,""minimum_price"":2.0,""band_id"":4221777153,""credits"":null,""killed"":null,""title"":""The Flame of Love"",""release_date"":""24 Jan 2020 00:00:00 GMT"",""require_email"":null,""private"":null,""featured_track_id"":3376198309,""audit"":0,""id"":1876398730,""auto_repriced"":null,""require_email_0"":null,""is_set_price"":null,""publish_date"":""23 Jan 2020 22:10:00 GMT"",""new_date"":""23 Jan 2020 21:56:40 GMT"",""upc"":null,""type"":""album"",""artist"":""David Lynch Featuring Jack Cruz"",""purchase_url"":null,""download_desc_id"":null,""new_desc_format"":1}, is_preorder: null, album_is_preorder: null, album_release_date: ""24 Jan 2020 00:00:00 GMT"", preorder_count: null, hasAudio: true, art_id: 3619351691, trackinfo: [{""video_id"":null,""video_mobile_url"":null,""duration"":107.021,""album_preorder"":false,""encoding_pending"":null,""is_draft"":false,""has_free_download"":null,""video_poster_url"":null,""unreleased_track"":false,""play_count"":0,""free_album_download"":false,""video_caption"":null,""title_link"":""/track/true-loves-flame"",""title"":""True Love's Flame"",""is_capped"":false,""sizeof_lyrics"":0,""private"":null,""track_license_id"":null,""video_featured"":null,""has_lyrics"":false,""track_id"":3376198309,""video_source_type"":null,""encodings_id"":3758270545,""id"":3376198309,""alt_link"":null,""has_info"":false,""video_source_id"":null,""lyrics"":null,""track_num"":1,""file"":{""mp3-128"":""https://t4.bcbits.com/stream/2edaf3cfa33ad6085025386d2c07310a/mp3-128/3376198309?p=0&ts=1580123227&t=cf59e8710bd0eaab7be3c8f9d84451f9a6250f4b&token=1580123227_1000fc623f7b17f8fb46aba812c2cecd20629982""},""encoding_error"":null,""is_downloadable"":true,""streaming"":1,""license_type"":1},{""video_id"":null,""video_mobile_url"":null,""duration"":208.167,""album_preorder"":false,""encoding_pending"":null,""is_draft"":false,""has_free_download"":null,""video_poster_url"":null,""unreleased_track"":false,""play_count"":0,""free_album_download"":false,""video_caption"":null,""title_link"":""/track/dancin-in-the-world-of-love"",""title"":""Dancin' in the World of Love"",""is_capped"":false,""sizeof_lyrics"":0,""private"":null,""track_license_id"":null,""video_featured"":null,""has_lyrics"":false,""track_id"":3779657492,""video_source_type"":null,""encodings_id"":3154011442,""id"":3779657492,""alt_link"":null,""has_info"":false,""video_source_id"":null,""lyrics"":null,""track_num"":2,""file"":{""mp3-128"":""https://t4.bcbits.com/stream/6463f0f38077f503ee9b619f2f50bdee/mp3-128/3779657492?p=0&ts=1580123227&t=85774f46e0224ff4738cb0dbffc7993e9363582e&token=1580123227_3c1fdd2f208a3de64ac025a33b57848cc4b08605""},""encoding_error"":null,""is_downloadable"":true,""streaming"":1,""license_type"":1}], playing_from: ""album page"", featured_track_id: 3376198309, initial_track_num: null, packages: [{""edition_size"":null,""tax_rate"":null,""country"":null,""label"":""Sacred Bones Records"",""selling_band_id"":237579501,""album_artist"":""David Lynch Featuring Jack Cruz"",""album_art"":null,""currency"":""USD"",""grid_index"":0,""album_title"":""The Flame of Love"",""quantity_limits"":92,""arts"":[{""file_name"":""3954342858"",""height"":1052,""index"":0,""id"":2948625657,""width"":1400,""image_id"":18475608}],""featured_date"":null,""download_title"":""The Flame of Love"",""subscriber_only"":null,""quantity_warning"":false,""download_url"":""https://davidlynch.bandcamp.com/album/the-flame-of-love"",""options"":null,""band_id"":4221777153,""title"":""Black Vinyl 7\"",""certified_seller"":1,""quantity_sold"":null,""release_date"":null,""download_has_audio"":true,""sku"":""SBR-252-BLACK"",""price"":8.0,""private"":null,""subscriber_only_published"":false,""album_private"":null,""download_id"":1876398730,""album_art_id"":3619351691,""description"":""Preorder. Ships late spring 2020."",""url"":""https://davidlynch.bandcamp.com/album/the-flame-of-love"",""new_date"":""23 Jan 2020 22:21:48 GMT"",""download_art_id"":3619351691,""origins"":[{""option_id"":0,""quantity_sold"":null,""package_id"":3434808363,""id"":12009,""quantity_available"":923,""quantity"":null}],""options_title"":null,""is_set_price"":null,""id"":3434808363,""album_release_date"":""24 Jan 2020 00:00:00 GMT"",""quantity_available"":923,""shipping_exception_mode"":null,""upc"":null,""desc_pt1"":""Preorder. Ships late spring 2020."",""associated_license_id"":null,""album_publish_date"":""23 Jan 2020 22:10:00 GMT"",""album_id"":1876398730,""fulfillment_days"":2,""download_artist"":""David Lynch Featuring Jack Cruz"",""download_type"":""a"",""type_id"":16,""new_desc_format"":1,""desc_pt2"":null,""type_name"":""7\"" Vinyl""},{""edition_size"":null,""tax_rate"":null,""country"":null,""label"":""Sacred Bones Records"",""selling_band_id"":237579501,""album_artist"":""David Lynch Featuring Jack Cruz"",""album_art"":null,""currency"":""USD"",""grid_index"":0,""album_title"":""The Flame of Love"",""quantity_limits"":79,""arts"":[{""file_name"":""391432930"",""height"":1052,""index"":0,""id"":4098056500,""width"":1400,""image_id"":18475616}],""featured_date"":null,""download_title"":""The Flame of Love"",""subscriber_only"":null,""quantity_warning"":false,""download_url"":""https://davidlynch.bandcamp.com/album/the-flame-of-love"",""options"":null,""band_id"":4221777153,""title"":""Clear Vinyl 7\"",""certified_seller"":1,""quantity_sold"":null,""release_date"":null,""download_has_audio"":true,""sku"":""SBR-252-CLEAR"",""price"":10.0,""private"":null,""subscriber_only_published"":false,""album_private"":null,""download_id"":1876398730,""album_art_id"":3619351691,""description"":""Preorder. Ships late spring 2020."",""url"":""https://davidlynch.bandcamp.com/album/the-flame-of-love"",""new_date"":""23 Jan 2020 22:22:25 GMT"",""download_art_id"":3619351691,""origins"":[{""option_id"":0,""quantity_sold"":null,""package_id"":3190193752,""id"":12009,""quantity_available"":799,""quantity"":null}],""options_title"":null,""is_set_price"":null,""id"":3190193752,""album_release_date"":""24 Jan 2020 00:00:00 GMT"",""quantity_available"":799,""shipping_exception_mode"":null,""upc"":null,""desc_pt1"":""Preorder. Ships late spring 2020."",""associated_license_id"":null,""album_publish_date"":""23 Jan 2020 22:10:00 GMT"",""album_id"":1876398730,""fulfillment_days"":2,""download_artist"":""David Lynch Featuring Jack Cruz"",""download_type"":""a"",""type_id"":16,""new_desc_format"":1,""desc_pt2"":null,""type_name"":""7\"" Vinyl""}], url: ""http://davidlynch.bandcamp.com"" + ""/album/the-flame-of-love"", defaultPrice: 7.0, freeDownloadPage: null, FREE: 1, PAID: 2, artist: ""David Lynch Featuring Jack Cruz"", item_type: ""album"", // xxx: note - don't internationalize this variable id: 1876398730, last_subscription_item: null, has_discounts: null, is_bonus: null, play_cap_data: {""streaming_limit"":3,""streaming_limits_enabled"":true}, client_id_sig: null, is_purchased: null, items_purchased: null, is_private_stream: null, is_band_member: null, licensed_version_ids: null, package_associated_license_id: null, tralbum_collect_info: {""show_collect"":true,""show_wishlist_tooltip"":false} } "; RegexOptions options = RegexOptions.Multiline; foreach (Match m in Regex.Matches(input, pattern, options)) { Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index); } } }

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 C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx