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

/
/

Test String

Code Generator

Generated Code

const regex = /^\+?([87](?!95[5-79]|99[08]|907|94[^0]|336)([348]\d|9[0-6789]|7[01247])\d{8}|[1246]\d{9,13}|68\d{7}|5[1-46-9]\d{8,12}|55[1-9]\d{9}|55[138]\d{10}|55[1256][14679]9\d{8}|554399\d{7}|500[56]\d{4}|5016\d{6}|5068\d{7}|502[45]\d{7}|5037\d{7}|50[4567]\d{8}|50855\d{4}|509[34]\d{7}|376\d{6}|855\d{8,9}|856\d{10}|85[0-4789]\d{8,10}|8[68]\d{10,11}|8[14]\d{10}|82\d{9,10}|852\d{8}|90\d{10}|96(0[79]|17[0189]|181|13)\d{6}|96[23]\d{9}|964\d{10}|96(5[569]|89)\d{7}|96(65|77)\d{8}|92[023]\d{9}|91[1879]\d{9}|9[34]7\d{8}|959\d{7,9}|989\d{9}|971\d{8,9}|97[02-9]\d{7,11}|99[^4568]\d{7, 11}|994\d{9}|9955\d{8}|996[2579]\d{8}|9989\d{8}|380[345679]\d{8}|381\d{9}|38[57]\d{8,9}|375[234]\d{8}|372\d{7,8}|37[0-4]\d{8}|37[6-9]\d{7,11}|30[69]\d{9}|506\d{9}|386\d{9}|965\d{9}|373\d{9}|856\d{9}|371\d{9}|996\d{9}|507\d{9}|509\d{9}|502\d{9}|374\d{9}|375\d{9}|95\d{10}|966\d{9}|503\d{9}|505\d{9}|501\d{9}|961\d{9}|389\d{9}|370\d{9}|93\d{10}|34[67]\d{8}|998\d{9}|993\d{9}|992\d{9}|968\d{9}|3459\d{11}|7\d{11}|967\d{9}|92\d{10}|964\d{9}|98\d{10}|34\d{10}|94\d{10}|372\d{9}|380\d{9}|995\d{9}|30\d{10}|960\d{9}|3[12359]\d{8,12}|36\d{9,10}|38[169]\d{8}|382\d{8,9}|46719\d{10})$/; // Alternative syntax using RegExp constructor // const regex = new RegExp('^\\+?([87](?!95[5-79]|99[08]|907|94[^0]|336)([348]\\d|9[0-6789]|7[01247])\\d{8}|[1246]\\d{9,13}|68\\d{7}|5[1-46-9]\\d{8,12}|55[1-9]\\d{9}|55[138]\\d{10}|55[1256][14679]9\\d{8}|554399\\d{7}|500[56]\\d{4}|5016\\d{6}|5068\\d{7}|502[45]\\d{7}|5037\\d{7}|50[4567]\\d{8}|50855\\d{4}|509[34]\\d{7}|376\\d{6}|855\\d{8,9}|856\\d{10}|85[0-4789]\\d{8,10}|8[68]\\d{10,11}|8[14]\\d{10}|82\\d{9,10}|852\\d{8}|90\\d{10}|96(0[79]|17[0189]|181|13)\\d{6}|96[23]\\d{9}|964\\d{10}|96(5[569]|89)\\d{7}|96(65|77)\\d{8}|92[023]\\d{9}|91[1879]\\d{9}|9[34]7\\d{8}|959\\d{7,9}|989\\d{9}|971\\d{8,9}|97[02-9]\\d{7,11}|99[^4568]\\d{7, 11}|994\\d{9}|9955\\d{8}|996[2579]\\d{8}|9989\\d{8}|380[345679]\\d{8}|381\\d{9}|38[57]\\d{8,9}|375[234]\\d{8}|372\\d{7,8}|37[0-4]\\d{8}|37[6-9]\\d{7,11}|30[69]\\d{9}|506\\d{9}|386\\d{9}|965\\d{9}|373\\d{9}|856\\d{9}|371\\d{9}|996\\d{9}|507\\d{9}|509\\d{9}|502\\d{9}|374\\d{9}|375\\d{9}|95\\d{10}|966\\d{9}|503\\d{9}|505\\d{9}|501\\d{9}|961\\d{9}|389\\d{9}|370\\d{9}|93\\d{10}|34[67]\\d{8}|998\\d{9}|993\\d{9}|992\\d{9}|968\\d{9}|3459\\d{11}|7\\d{11}|967\\d{9}|92\\d{10}|964\\d{9}|98\\d{10}|34\\d{10}|94\\d{10}|372\\d{9}|380\\d{9}|995\\d{9}|30\\d{10}|960\\d{9}|3[12359]\\d{8,12}|36\\d{9,10}|38[169]\\d{8}|382\\d{8,9}|46719\\d{10})$', '') const str = ``; // Reset `lastIndex` if this regex is defined globally // regex.lastIndex = 0; let m; if ((m = regex.exec(str)) !== null) { // 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