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
No Match

/
/
img

Test String

Code Generator

Generated Code

#include <StringConstants.au3> ; to declare the Constants of StringRegExp #include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate Local $sRegex = "(?im)<!-- AppInternalsXpert BMX Integration Begin -->(.*[\s\S]*)<!-- AppInternalsXpert BMX Integration End -->" Local $sString = "" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ "<script>" & @CRLF & _ "$(function() {" & @CRLF & _ " $( ".tabs" ).tabs();" & @CRLF & _ " });" & @CRLF & _ "</script>" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " <!-- AppInternalsXpert BMX Integration Begin -->" & @CRLF & _ " <script>" & @CRLF & _ " if(!RVBD_EUE){" & @CRLF & _ " var RVBD_EUE={startJS:Number(new Date())," & @CRLF & _ " clientId:'',appId:1," & @CRLF & _ " collector:'apmperformance.correios.com.br'," & @CRLF & _ " collectorHttpPort:80, collectorHttpsPort:443," & @CRLF & _ " sv:'0401'," & @CRLF & _ " ajax:true, sync:true," & @CRLF & _ " ajaxResponseTime:true};" & @CRLF & _ " (function(){" & @CRLF & _ " var w=window,l=w.addEventListener,m=w.attachEvent," & @CRLF & _ " d=document,s='script',t='load',o=RVBD_EUE," & @CRLF & _ " r=(('https:'===d.location.protocol)?" & @CRLF & _ " 'https://apmperformance.correios.com.br:443':" & @CRLF & _ " 'http://apmperformance.correios.com.br:80')+" & @CRLF & _ " '/jsi/riverbed_appinternals.d.'+" & @CRLF & _ " (o.ajax?'ajax.js':'js'),p=('onpagehide' in w),e=p?'pageshow':t," & @CRLF & _ " j=d.createElement(s),x=d.getElementsByTagName(s)[0]," & @CRLF & _ " h=function(y){o.ldJS=o.ldJS||new Date();o.per=y?y.persisted:null;}," & @CRLF & _ " i=function(){o.ld=1;};o.cookie=d.cookie;d.cookie=" & @CRLF & _ " '_op_aixPageId=0; path=/; expires='+(new Date(0)).toGMTString();" & @CRLF & _ " o.cookieAfterDelete=d.cookie;j.async=1;j.src=r;" & @CRLF & _ " if(l){l(e,h,false);if(p){l(t,i,false);}}else if(m)" & @CRLF & _ " {m('on'+e,h);if(p){m('on'+t,i);}}" & @CRLF & _ " if(o.sync){d.write('<'+s+' src=\''+r+'\'></'+s+'>');}" & @CRLF & _ " else{x.parentNode.insertBefore(j,x);}" & @CRLF & _ " })();}" & @CRLF & _ " </script>" & @CRLF & _ " <script>if(!RVBD_EUE_PARAM){var RVBD_EUE_PARAM={};} RVBD_EUE_PARAM.pageId = 'a2_e6e8c617-d7ec-4acd-a432-08b0febc30e0';</script> " & @CRLF & _ " <!-- AppInternalsXpert BMX Integration End -->" & @CRLF & _ " [cadastrado]" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH) Local $aFullArray[0] For $i = 0 To UBound($aArray) -1 _ArrayConcatenate($aFullArray, $aArray[$i]) Next $aArray = $aFullArray ; Present the entire match result _ArrayDisplay($aArray, "Result")

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 AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm