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

/
/
i

Test String

Code Generator

Generated Code

$re = '/__typename":"GraphImage","id":"(.*?)","edge_media_to_caption":{"edges":\[{"node":{"text":"(.*?)"}}]},"shortcode":"(.*?)","edge_media_to_comment":{"count":(.*?)},"comments_disabled":false,"taken_at_timestamp":(.*?),"dimensions":{"height":(.*?),"width":(.*?)},"display_url":"(.*?)","edge_liked_by"/i'; $str = '/27891564_190819718336556_2731792619813208064_n.jpg?_nc_ht=instagram.fdel1-4.fna.fbcdn.net","requested_by_viewer":false,"username":"ziynetaki","connected_fb_page":null,"edge_felix_video_timeline":{"count":0,"page_info":{"has_next_page":false,"end_cursor":null},"edges":[]},"edge_owner_to_timeline_media":{"count":4,"page_info":{"has_next_page":false,"end_cursor":null},"edges":[{"node":{"__typename":"GraphImage","id":"1998193948597745904","edge_media_to_caption":{"edges":[{"node":{"text":"test"}}]},"shortcode":"Bu7As8ygPjw","edge_media_to_comment":{"count":0},"comments_disabled":false,"taken_at_timestamp":1552423302,"dimensions":{"height":216,"width":320},"display_url":"https://instagram.fdel1-4.fna.fbcdn.net/vp/b26fc82649aebaba80ff8750844d9476/5D32EFAE/t51.2885-15/e35/52508202_381950182383672_2887085630092404003_n.jpg?_nc_ht=instagram.fdel1-4.fna.fbcdn.net","edge_liked_by":{"count":6},"edge_media_preview_like":{"count":6},"location":null,"gating_info":null,"media_preview":"ACoc6SiiigAooooAKKKKACiiigAooooAKKKKAP/Z","owner":{"id":"7101789977","username":"ziynetaki"},"thumbnail_src":"https://instagram.fdel1-4.fna.fbcdn.net/vp/7d5606659a99d7a3b8f4d941f8d33a19/5D171D3A/t51.2885-15/e35/c52.0.216.216,"p":{"show_feedback":"false"}},"igwspe":{"g":"has_sensitivity_screen","p":{"has_stories_sensitivity_screen":"true"}},"0":{"p":{"0":false,"1":false,"2":false},"qex":true},"2":{"p":{"0":false},"qex":true},"3":{"p":{"0":false},"qex":true},"4":{"p":{"0":false},"qex":true},"5":{"p":{"0":false},"qex":true}},"probably_has_app":true},"rollout_hash":"01e70cf96366","bundle_variant":"es6","is_canary":false};</script> '; preg_match($re, $str, $matches, PREG_OFFSET_CAPTURE, 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