Regular Expressions 101

Save & Share

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

/
/
g

Test String

Code Generator

Generated Code

use strict; my $str = '{"\\"mouse-pointer\\"":59057,"\\r\\n\\"pointer\\"":59058,"\\r\\n\\"hand\\"":59059,"\\r\\n\\"question-mark\\"":59060,"\\r\\n\\"airplay\\"":58880,"\\r\\n\\"apn\\"":58882,"\\r\\n\\"vpn\\"":58883,"\\r\\n\\"apple\\"":58884,"\\r\\n\\"windows\\"":58885,"\\r\\n\\"android\\"":58886,"\\r\\n\\"wifi\\"":58887,"\\r\\n\\"battery\\"":58890,"\\r\\n\\"camera\\"":58899,"\\r\\n\\"notification\\"":58891,"\\r\\n\\"settings\\"":58991,"\\r\\n\\"send\\"":58986,"\\r\\n\\"bookmark\\"":58893,"\\r\\n\\"bug\\"":58897,"\\r\\n\\"clock\\"":58909,"\\r\\n\\"calendar\\"":58898,"\\r\\n\\"add\\"":58901,"\\r\\n\\"minus\\"":58902,"\\r\\n\\"check\\"":58903,"\\r\\n\\"cancel\\"":58904,"\\r\\n\\"list\\"":58956,"\\r\\n\\"checklist\\"":58905,"\\r\\n\\"grid\\"":58936,"\\r\\n\\"dots\\"":58921,"\\r\\n\\"menu\\"":58961,"\\r\\n\\"tiles\\"":59009,"\\r\\n\\"clear\\"":58907,"\\r\\n\\"clear-passcode\\"":58908,"\\r\\n\\"enterprise-wipe\\"":58927,"\\r\\n\\"cloud\\"":58910,"\\r\\n\\"contact\\"":58912,"\\r\\n\\"copy\\"":58913,"\\r\\n\\"paste\\"":58968,"\\r\\n\\"undo\\"":59011,"\\r\\n\\"redo\\"":58973,"\\r\\n\\"dashboard\\"":58914,"\\r\\n\\"view\\"":59025,"\\r\\n\\"focus\\"":59061,"\\r\\n\\"delete\\"":58916,"\\r\\n\\"save\\"":58981,"\\r\\n\\"register\\"":58974,"\\r\\n\\"change-passcode\\"":58900,"\\r\\n\\"edit\\"":58924,"\\r\\n\\"sign-up\\"":58993,"\\r\\n\\"deploy\\"":58917,"\\r\\n\\"dial-up\\"":58919,"\\r\\n\\"dss\\"":58922,"\\r\\n\\"ebook\\"":58923,"\\r\\n\\"import\\"":58940,"\\r\\n\\"export\\"":58929,"\\r\\n\\"factory-reset\\"":58930,"\\r\\n\\"file-browse\\"":58931,"\\r\\n\\"grouping\\"":59055,"\\r\\n\\"folder\\"":59062,"\\r\\n\\"filter\\"":58932,"\\r\\n\\"sort\\"":58995,"\\r\\n\\"sort-up\\"":58955,"\\r\\n\\"sort-down\\"":58979,"\\r\\n\\"faq\\"":59063,"\\r\\n\\"message\\"":58933,"\\r\\n\\"forum\\"":58934,"\\r\\n\\"chat\\"":59064,"\\r\\n\\"mail\\"":58959,"\\r\\n\\"invitation\\"":58943,"\\r\\n\\"usb-drive\\"":59022,"\\r\\n\\"hdd\\"":58937,"\\r\\n\\"home\\"":58938,"\\r\\n\\"hour-glass\\"":58939,"\\r\\n\\"incoming-call\\"":58941,"\\r\\n\\"key\\"":58951,"\\r\\n\\"lifecycle\\"":58954,"\\r\\n\\"list-sort\\"":58957,"\\r\\n\\"lock\\"":58958,"\\r\\n\\"map-location\\"":58960,"\\r\\n\\"laptop\\"":58952,"\\r\\n\\"mobile\\"":58962,"\\r\\n\\"ringing\\"":59028,"\\r\\n\\"computer\\"":58963,"\\r\\n\\"devices\\"":58918,"\\r\\n\\"mute\\"":58965,"\\r\\n\\"unmute\\"":59054,"\\r\\n\\"ok\\"":58967,"\\r\\n\\"error\\"":58928,"\\r\\n\\"circle\\"":58906,"\\r\\n\\"ring\\"":58911,"\\r\\n\\"pdf\\"":58969,"\\r\\n\\"ms-document\\"":58964,"\\r\\n\\"pie-chart\\"":58970,"\\r\\n\\"bar-chart\\"":59056,"\\r\\n\\"publish\\"":58972,"\\r\\n\\"resource\\"":58976,"\\r\\n\\"rules\\"":58980,"\\r\\n\\"scep\\"":58982,"\\r\\n\\"security\\"":58985,"\\r\\n\\"search\\"":58984,"\\r\\n\\"sequence\\"":58987,"\\r\\n\\"servers\\"":58988,"\\r\\n\\"ldap\\"":58953,"\\r\\n\\"database\\"":58915,"\\r\\n\\"hardware\\"":59049,"\\r\\n\\"signal\\"":59065,"\\r\\n\\"raspberry\\"":59050,"\\r\\n\\"arduino\\"":59051,"\\r\\n\\"share\\"":58992,"\\r\\n\\"star\\"":58996,"\\r\\n\\"coins\\"":59066,"\\r\\n\\"statistics\\"":58997,"\\r\\n\\"store\\"":58998,"\\r\\n\\"subscribe\\"":58999,"\\r\\n\\"fan\\"":59067,"\\r\\n\\"light\\"":59068,"\\r\\n\\"subscribed-calendar\\"":59000,"\\r\\n\\"tag\\"":59002,"\\r\\n\\"tasks\\"":59003,"\\r\\n\\"blank-document\\"":58892,"\\r\\n\\"document\\"":58920,"\\r\\n\\"text\\"":59004,"\\r\\n\\"policy\\"":59005,"\\r\\n\\"security-policy\\"":59006,"\\r\\n\\"throttling-policy\\"":59007,"\\r\\n\\"ticked-box\\"":59008,"\\r\\n\\"uncheck\\"":59010,"\\r\\n\\"upload\\"":59020,"\\r\\n\\"download\\"":58975,"\\r\\n\\"up\\"":59012,"\\r\\n\\"down\\"":59013,"\\r\\n\\"left\\"":59014,"\\r\\n\\"right\\"":59015,"\\r\\n\\"up-arrow\\"":59016,"\\r\\n\\"down-arrow\\"":59017,"\\r\\n\\"left-arrow\\"":59018,"\\r\\n\\"right-arrow\\"":59019,"\\r\\n\\"endpoint\\"":58925,"\\r\\n\\"uri\\"":59021,"\\r\\n\\"broken-link\\"":58896,"\\r\\n\\"user\\"":59023,"\\r\\n\\"add-user\\"":59024,"\\r\\n\\"refresh\\"":59026,"\\r\\n\\"warning\\"":59027,"\\r\\n\\"info\\"":58942,"\\r\\n\\"block\\"":59029,"\\r\\n\\"bpmn\\"":58895,"\\r\\n\\"schema\\"":58983,"\\r\\n\\"organization\\"":59052,"\\r\\n\\"public\\"":59053,"\\r\\n\\"bpel\\"":58894,"\\r\\n\\"application\\"":58888,"\\r\\n\\"applications\\"":58889,"\\r\\n\\"public-app\\"":58971,"\\r\\n\\"enterprise-app\\"":58926,"\\r\\n\\"web-app\\"":59030,"\\r\\n\\"globe\\"":59031,"\\r\\n\\"webclip\\"":59032,"\\r\\n\\"proxy\\"":59033,"\\r\\n\\"web-service\\"":59034,"\\r\\n\\"website\\"":59035,"\\r\\n\\"gadget\\"":58935,"\\r\\n\\"api\\"":58881,"\\r\\n\\"rest-api\\"":58977,"\\r\\n\\"rest-service\\"":58978,"\\r\\n\\"jaxrs\\"":58949,"\\r\\n\\"service\\"":58989,"\\r\\n\\"service-provider\\"":58990,"\\r\\n\\"java-spring\\"":58948,"\\r\\n\\"jquery\\"":58950,"\\r\\n\\"swagger\\"":59001,"\\r\\n\\"java\\"":58945,"\\r\\n\\"javaee\\"":58946,"\\r\\n\\"javascript\\"":58947,"\\r\\n\\"jaggery\\"":58944,"\\r\\n\\"nodejs\\"":58966,"\\r\\n\\"xml\\"":59036,"\\r\\n\\"soap\\"":58994,"\\r\\n\\"html\\"":59037,"\\r\\n\\"war\\"":59038,"\\r\\n\\"xacml\\"":59039,"\\r\\n\\"wsdl\\"":59040,"\\r\\n\\"wadl\\"":59041,"\\r\\n\\"xq\\"":59042,"\\r\\n\\"xsd\\"":59043,"\\r\\n\\"xslt\\"":59044,"\\r\\n\\"zoom-in\\"":59045,"\\r\\n\\"zoom-out\\"":59046,"\\r\\n\\"wso2-logo\\"":59047,"\\r\\n\\"wso2\\"":59048}'; my $regex = qr/(?:\\[rn"\"]|[\r\n]+)+/p; if ( $str =~ /$regex/g ) { print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n"; # print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n"; # print "Capture Group 2 is $2 ... and so on\n"; } # ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p' # Named capture groups can be called via $+{name}

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 Perl, please visit: http://perldoc.perl.org/perlre.html