Regular Expressions 101

Save & Share

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

#include <StringConstants.au3> ; to declare the Constants of StringRegExp #include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate Local $sRegex = "(?m)(([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)(\s*;\s*|\s*$))*" Local $sString = "a@a.c" & @CRLF & _ "a@a.co" & @CRLF & _ "sbreedebd@home.pl" & @CRLF & _ "sgerrensbe@free.fr" & @CRLF & _ "eishakbf@skyrock.com" & @CRLF & _ "dstansallbg@japanpost.jp" & @CRLF & _ "mbrittanbh@amazon.co.uk" & @CRLF & _ "slauridsenbi@home.pl" & @CRLF & _ "dgrabbambj@imageshack.us" & @CRLF & _ "etossellbk@apple.com" & @CRLF & _ "smoodycliffebl@sogou.com" & @CRLF & _ "rtoothillbm@wisc.edu" & @CRLF & _ "asebbornbn@infoseek.co.jp" & @CRLF & _ "dgherardescibo@jalbum.net" & @CRLF & _ "aarnaldybp@europa.eu" & @CRLF & _ "aballantinebq@bigcartel.com" & @CRLF & _ "cgiraudatbr@phpbb.com" & @CRLF & _ "hmaccoughenbs@answers.com" & @CRLF & _ "emattessenbt@dot.gov" & @CRLF & _ "saronowbu@exblog.jp" & @CRLF & _ "ckorneichukbv@berkeley.edu" & @CRLF & _ "nroderigobw@yale.edu" & @CRLF & _ "ealeksandrevbx@netvibes.com" & @CRLF & _ "ebolterby@eepurl.com" & @CRLF & _ "cgaitherbz@theatlantic.com" & @CRLF & _ "sfeedomec0@shutterfly.com" & @CRLF & _ "ahatfullc1@ocn.ne.jp" & @CRLF & _ "mbythwayc2@whitehouse.gov" & @CRLF & _ "mleitherc3@dyndns.org" & @CRLF & _ "gtouretc4@icq.com" & @CRLF & _ "lmcnaec5@cam.ac.uk" & @CRLF & _ "tculveyc6@si.edu" & @CRLF & _ "fportwainc7@themeforest.net" & @CRLF & _ "eshivellc8@xing.com" & @CRLF & _ "mrheltonc9@howstuffworks.com" & @CRLF & _ "rrenodenca@walmart.com" & @CRLF & _ "ibaudcb@apple.com" & @CRLF & _ "amckerncc@domainmarket.com" & @CRLF & _ "aszymczykcd@vk.com" & @CRLF & _ "edittyce@patch.com" & @CRLF & _ "eibertcf@cyberchimps.com" & @CRLF & _ "apagencg@google.cn" & @CRLF & _ "bcousinsch@elpais.com" & @CRLF & _ "edockrellci@kickstarter.com" & @CRLF & _ "peasterlingcj@vkontakte.ru" & @CRLF & _ "mmoenck@mail.ru" & @CRLF & _ "nstitwellcl@admin.ch" & @CRLF & _ "mreginacm@techcrunch.com" & @CRLF & _ "fbindoncn@nps.gov" & @CRLF & _ "vpocklingtonco@seattletimes.com" & @CRLF & _ "lbarabichcp@privacy.gov.au" & @CRLF & _ "fmcbeathcq@thetimes.co.uk" & @CRLF & _ "jbohillscr@bandcamp.com" & @CRLF & _ "aworkescs@amazon.de" & @CRLF & _ "mmarusyakct@zdnet.com" & @CRLF & _ "lmcaleescu@simplemachines.org" & @CRLF & _ "bdemetzcv@illinois.edu" & @CRLF & _ "jdominiquecw@economist.com" & @CRLF & _ "easlottcx@ftc.gov" & @CRLF & _ "adewhirstcy@marriott.com" & @CRLF & _ "mstaddomcz@slideshare.net" & @CRLF & _ "aealamd0@ibm.com" & @CRLF & _ "dweblind1@youtube.com" & @CRLF & _ "palasdaird2@unesco.org" & @CRLF & _ "rfrearsond3@disqus.com" & @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