Regular Expressions 101

Save & Share

  • Regex Version: ver. 4
  • 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

$re = '/(?<=authorization:\s)([\w-.]+)(?=\' \^)/m'; $str = 'curl \'https://i-tools.cys.com/api/v1/places/nearby?latitude=-6.30491801&longitude=106.6861089&radius_in_km=0.5&providers=internaltopv2&limit=10&msg_id=aa0cabd1-db82-11ea-af17-1d5f5xxxxx\' \\ -H \'authority: i-tools.cys.com\' \\ -H \'accept: application/json, text/plain, */*\' \\ -H \'authorization: axZhbGciOiJSUzI1NiIsImtpZCI6Il9kZWZhdWx0IiwidHlwIjoiSldUIn0.eyJhdWQiOiJHRU8tVE9PTFMiLCJleHAiOjE2MDgxMDgxNDYsImlhdCI6MTYwODAyMTc0MywianRpIjoiNDA2NjI5NzgtN2RmMS00MDE5LThjZTktMTZkMTFlMjY4NmYyIiwibG1lIjoiR09PR0xFVjMiLCJuYW1lIjoiIiwic3ViIjoiNWU1ZWQyM2YtNGRkMi00YmY3LThkNTEtZGM0MzY0NDdmNzg5In0.IXBubd0NrCaVEyrnaskH4CO50nP5qLz-6G02IBpy0vnPAjHcFeLd4OdocN2TinuBiK_LtgIfIgLCOJx_A3hsNCqnAbIRKfKV6b7xO7HSLNXIT3PS8iAy_z2I5bW4-hUcKJkrMJcgHA8j2bBZGlAPaDf6PkjdzFM7M0P_kXk5H_zKyO2prAQA-eh3UYUr22PLptLsusWMAfXFGf42eUoNz6gq8KKWzaO0wc7FqrYD-rLz50xDMuwLS9J-su4TzIhpJgaMKq8rIvNyy5nAs-77IhG_foaIelVY6ZGFgUe_dvq0Ox9JrR8tqLV7kRwMf7EAIgbdKN-Xxu8ZbulhhuxNZA\' ^ -H \'i-tools-params: {"client_version":"v11.0.1xxxx"}\' \\ -H \'user-agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Mobile Safari/537.36\' \\ -H \'x-app-identity: i_tools\' \\ -H \'origin: https://i-tools.cys.net\' \\ -H \'sec-fetch-site: cross-site\' \\ -H \'sec-fetch-mode: cors\' \\ -H \'sec-fetch-dest: empty\' \\ -H \'referer: https://i-tools.cys.net/ops-tools/place-nearby-v2\' \\ -H \'accept-language: id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7\' \\ --compressed'; 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