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

const regex = /(?<=authorization:\s)([\w-.]+)(?=' \^)/gm; // Alternative syntax using RegExp constructor // const regex = new RegExp('(?<=authorization:\\s)([\\w-.]+)(?=\' \\^)', 'gm') const 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`; // Reset `lastIndex` if this regex is defined globally // regex.lastIndex = 0; let m; while ((m = regex.exec(str)) !== null) { // This is necessary to avoid infinite loops with zero-width matches if (m.index === regex.lastIndex) { regex.lastIndex++; } // The result can be accessed through the `m`-variable. m.forEach((match, groupIndex) => { console.log(`Found match, group ${groupIndex}: ${match}`); }); }

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 JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions