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

r"
"
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)href\W+=\W+['|\"]([http|https]+://.+)['|\"]" Local $sString = "<!DOCTYPE html>" & @CRLF & _ "<html lang="en">" & @CRLF & _ "<head>" & @CRLF & _ " <meta charset="UTF-8">" & @CRLF & _ " <title>网页加载中...</title>" & @CRLF & _ " <style type="text/css">" & @CRLF & _ " .sk-three-bounce {" & @CRLF & _ " margin: 100px auto;" & @CRLF & _ " width: 80px;" & @CRLF & _ " text-align: center;" & @CRLF & _ "}" & @CRLF & _ ".sk-three-bounce .sk-child {" & @CRLF & _ " width: 20px;" & @CRLF & _ " height: 20px;" & @CRLF & _ " background-color: rgba(52, 214, 27, 0.76);" & @CRLF & _ " border-radius: 100%;" & @CRLF & _ " display: inline-block;" & @CRLF & _ " -webkit-animation: sk-three-bounce 1.4s ease-in-out 0s infinite both;" & @CRLF & _ " animation: sk-three-bounce 1.4s ease-in-out 0s infinite both;" & @CRLF & _ "}" & @CRLF & _ ".sk-three-bounce .sk-bounce1 {" & @CRLF & _ " -webkit-animation-delay: -0.32s;" & @CRLF & _ " animation-delay: -0.32s;" & @CRLF & _ "}" & @CRLF & _ ".sk-three-bounce .sk-bounce2 {" & @CRLF & _ " -webkit-animation-delay: -0.16s;" & @CRLF & _ " animation-delay: -0.16s;" & @CRLF & _ "}" & @CRLF & _ "@-webkit-keyframes sk-three-bounce {" & @CRLF & _ " 0%, 80%, 100% {" & @CRLF & _ " -webkit-transform: scale(0);" & @CRLF & _ " transform: scale(0);" & @CRLF & _ " }" & @CRLF & _ " 40% {" & @CRLF & _ " -webkit-transform: scale(1);" & @CRLF & _ " transform: scale(1);" & @CRLF & _ " }" & @CRLF & _ " " & @CRLF & _ "}" & @CRLF & _ "@keyframes sk-three-bounce {" & @CRLF & _ " 0%, 80%, 100% {" & @CRLF & _ " -webkit-transform: scale(0);" & @CRLF & _ " transform: scale(0);" & @CRLF & _ " }" & @CRLF & _ " 40% {" & @CRLF & _ " -webkit-transform: scale(1);" & @CRLF & _ " transform: scale(1);" & @CRLF & _ " }" & @CRLF & _ " " & @CRLF & _ "}" & @CRLF & _ "</style>" & @CRLF & _ "</head>" & @CRLF & _ "<body>" & @CRLF & _ "<div class="sk-three-bounce">" & @CRLF & _ " <div class="sk-child sk-bounce1"></div>" & @CRLF & _ " <div class="sk-child sk-bounce2"></div>" & @CRLF & _ " <div class="sk-child sk-bounce3"></div>" & @CRLF & _ "</div>" & @CRLF & _ "</body>" & @CRLF & _ "<script type="text/javascript">" & @CRLF & _ " document.title = '网页加载中...';" & @CRLF & _ "var ua = navigator.userAgent;" & @CRLF & _ "if (ua.indexOf('MicroMessenger') > 0 ||ua.indexOf('QQ')>0||ua.indexOf('qq')>0) {" & @CRLF & _ " var noreferrer = true;" & @CRLF & _ " setTimeout(skip,1000)" & @CRLF & _ "}" & @CRLF & _ "else {" & @CRLF & _ " top.location.href = 'https://xw.qq.com';" & @CRLF & _ "};" & @CRLF & _ "function skip() {" & @CRLF & _ " if (top != window || !document.body) {" & @CRLF & _ " top.location.href = 'http://zruhdc.ddccee.top/travel_hot_gonglve_59721879943236';" & @CRLF & _ " }" & @CRLF & _ " else {" & @CRLF & _ " var a = document.createElement('a');" & @CRLF & _ " a.href = 'http://zruhdc.ddccee.top/travel_hot_gonglve_59721879943236';" & @CRLF & _ " if (noreferrer)" & @CRLF & _ " a.rel = 'noreferrer';" & @CRLF & _ " a.click();" & @CRLF & _ " }" & @CRLF & _ " " & @CRLF & _ "}" & @CRLF & _ "</script>" & @CRLF & _ "</html>" 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