Regular Expressions 101

Save & Share

  • Regex Version: ver. 3
  • 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
No Match

r"
"
gmix

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 = "(?mix)<p\s*" & @CRLF & _ "(?:[^>=]|='[^']*'|="[^"]*"|=[^'"][^\s>]*)*?\sclass=(['"]?)(?:body|bodydc)\1(?:\s|>)" & @CRLF & _ "" & @CRLF & _ "(?:([^<]*)|<(?!\/p)(?:[^>=]|='[^']*'|="[^"]*"|=[^'"][^\s>]*)*>)*" & @CRLF & _ "(?=<\/p>)" & @CRLF & _ "" Local $sString = "<p class=bodyDC style='text-indent:12.0pt'><span style='font-size:14.0pt;" & @CRLF & _ "mso-bidi-font-size:10.0pt' onmouseover=" </p> ">We have no need to fear the future.&quot; So said" & @CRLF & _ "bishop-elect H. George Anderson at a news conference immediately following his election as " & @CRLF & _ "bishop of the Evangelical Lutheran Church in America. &quot;[The" & @CRLF & _ "future] belongs­ to God, untouched by human hands.&quot; At the beginning of a" & @CRLF & _ "new ministry of leadership and pastoral oversight, such words from a bishop are" & @CRLF & _ "obviously designed to project confidence and a profound sense of trust in the" & @CRLF & _ "mission of the Church. They are words designed to inspire and empower the" & @CRLF & _ "people of God for ministry.<o:p></o:p></span></p>" & @CRLF & _ "Paragraph #2" & @CRLF & _ "" & @CRLF & _ "<p class=BODY><span style='font-size:14.0pt;mso-bidi-font-size:10.0pt'>Ages" & @CRLF & _ "ago, another prophet of the people stood at his station and peered into the" & @CRLF & _ "future. The<span style="mso-spacerun: yes"> </span>prophet Habakkuk poised on" & @CRLF & _ "the rampart, scanned the horizon for the approaching enemy he knew was coming." & @CRLF & _ "As he waited, Habakkuk prayed to God asking why God was unresponsive to all" & @CRLF & _ "this violence and destruction. In Habakkuk chapter 2 the prophet records God's" & @CRLF & _ "answer to his questions about the future. God says to the fearful one, &quot;For" & @CRLF & _ "there is still a vision for the appointed time;… If it seems to tarry, wait for" & @CRLF & _ "it; it will surely come, it will not delay…the righteous live by faith&quot;" & @CRLF & _ "(2:3-4).<o:p></o:p></span></p>" 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