Regular Expressions 101

Save & Share

  • Regex Version: ver. 5
  • 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 (1)

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)^(?!.*@media)[\t ]*([a-zA-Z#.:*[][^{\/]*\s*){[\s\S]*?}" Local $sString = "a {color: red !important;}" & @CRLF & _ " " & @CRLF & _ "#p1 {" & @CRLF & _ " margin-top: 20px !important" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ "/* Client-specific styles */" & @CRLF & _ "" & @CRLF & _ " .ExternalClass, " & @CRLF & _ " .ExternalClass p, " & @CRLF & _ " .ExternalClass span, " & @CRLF & _ " .ExternalClass font, " & @CRLF & _ " .ExternalClass td, " & @CRLF & _ " .ExternalClass div {" & @CRLF & _ " line-height: 100%;" & @CRLF & _ " }" & @CRLF & _ " " & @CRLF & _ " a {}" & @CRLF & _ "" & @CRLF & _ "@media query { " & @CRLF & _ "a { " & @CRLF & _ "display:none " & @CRLF & _ "} " & @CRLF & _ "}" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " a" & @CRLF & _ " { display:none } " & @CRLF & _ "}" & @CRLF & _ "" & @CRLF & _ "/* Media query for mobile viewport" & @CRLF & _ " #asset_container * Developer: hero graphics should be 2 x width for HD rendering." & @CRLF & _ " */ " & @CRLF & _ " @media only screen and (max-width: 480px){" & @CRLF & _ " table[class=max-width-pad] {" & @CRLF & _ " max-width: 100% !important;" & @CRLF & _ " width: 100% !important;" & @CRLF & _ " padding-top: 15px !important;" & @CRLF & _ " height: auto !important;" & @CRLF & _ " }" & @CRLF & _ " #asset_container table[class=max-width]{" & @CRLF & _ " max-width: 100% !important;" & @CRLF & _ " width: 100% !important;" & @CRLF & _ " height: auto !important;" & @CRLF & _ " }" & @CRLF & _ " #asset_container table[class=container]{" & @CRLF & _ " margin: 0 auto !important;" & @CRLF & _ " }" & @CRLF & _ " #asset_container .desktop-masthead{" & @CRLF & _ " display: none !important;" & @CRLF & _ " }" & @CRLF & _ " #asset_container *[class].hidden. *[class=desktop-masthead]{" & @CRLF & _ " display: none !important;" & @CRLF & _ " }" & @CRLF & _ " #asset_container *[class].elastic{" & @CRLF & _ " width: 100% !important;" & @CRLF & _ " height: auto !important;" & @CRLF & _ " }" & @CRLF & _ " #asset_container *[class].centered{" & @CRLF & _ " text-align: center !important;" & @CRLF & _ " }" & @CRLF & _ " #asset_container *[class].fluid, #asset_container [class=fluid-mob]{" & @CRLF & _ " width: 100% !important;" & @CRLF & _ " }" & @CRLF & _ " [class=fluid-mob] {" & @CRLF & _ " #asset_container position: relative;" & @CRLF & _ " }" & @CRLF & _ " .mobile-show{" & @CRLF & _ " display: table-cell !important;" & @CRLF & _ " width: auto !important;" & @CRLF & _ " height: auto !important;" & @CRLF & _ " max-height: none !important;" & @CRLF & _ " overflow: visible !important;" & @CRLF & _ " visibility: visible !important;" & @CRLF & _ " position: relative !important;" & @CRLF & _ " text-align: center !important;" & @CRLF & _ " }" & @CRLF & _ " #asset_container .show-mob{" & @CRLF & _ " display: block !important;" & @CRLF & _ " max-height: none !important;" & @CRLF & _ " width: auto !important;" & @CRLF & _ " visibility: visible !important;" & @CRLF & _ " }" & @CRLF & _ " #asset_container *[class].mob-masthead{" & @CRLF & _ " width: 100% !important;" & @CRLF & _ " display: block !important;" & @CRLF & _ " height: auto !important;" & @CRLF & _ " max-height: none !important;" & @CRLF & _ " padding: 0 !important;" & @CRLF & _ " }" & @CRLF & _ " #asset_container *[class].mob-masthead-img{" & @CRLF & _ " position: absolute !important;" & @CRLF & _ " top: 0px !important;" & @CRLF & _ " display: block !important;" & @CRLF & _ " height: auto !important;" & @CRLF & _ " max-height: none !important;" & @CRLF & _ " padding: 0 !important;" & @CRLF & _ " width: auto !important;" & @CRLF & _ " }" & @CRLF & _ " [class=fluid-mob] {" & @CRLF & _ " display: table-cell !important;" & @CRLF & _ " width: auto !important;" & @CRLF & _ " height: auto !important;" & @CRLF & _ " max-height: none !important;" & @CRLF & _ " overflow: visible !important;" & @CRLF & _ " visibility: visible !important;" & @CRLF & _ " position: relative !important;" & @CRLF & _ " text-align: center !important;" & @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