Regular Expressions 101

Save & Share

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

/
/
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)\s+(-[0-9A-Za-z]+|--[A-Za-z0-9][\w-]+)" Local $sString = "ignores position args" & @CRLF & _ "ignores-this _and_this _2 but-not -a -xvzf -4 -6 -Targ" & @CRLF & _ "ignores-echo -----------" & @CRLF & _ "ignores-mistaken --a did-you-mean -a" & @CRLF & _ " --3-2-pulldown" & @CRLF & _ " --3gpp-scan" & @CRLF & _ " --64" & @CRLF & _ " --802_3-sap" & @CRLF & _ " --802_3-type" & @CRLF & _ " --90" & @CRLF & _ " --abi-call0" & @CRLF & _ " --action1" & @CRLF & _ " --action9" & @CRLF & _ " --appData" & @CRLF & _ " --assume-utf16be" & @CRLF & _ " --assume-utf16le" & @CRLF & _ " --authValue" & @CRLF & _ " --aws-sigv4" & @CRLF & _ " --background_compression" & @CRLF & _ " --btf_encode" & @CRLF & _ " --cipherText" & @CRLF & _ " --Complain" & @CRLF & _ " --contains_enumerator" & @CRLF & _ " --data_replicas" & @CRLF & _ " --disable-pcre2-8" & @CRLF & _ " --disable-pcre2grep-callout" & @CRLF & _ " --disable-pcre2grep-callout-fork" & @CRLF & _ " --disable-pcre2grep-jit" & @CRLF & _ " --dns-ipv4-addr" & @CRLF & _ " --dns-ipv6-addr" & @CRLF & _ " --do-0x20-encode" & @CRLF & _ " --do-x20-encode" & @CRLF & _ " --dualprime-mpeg2" & @CRLF & _ " --eccpoint-L" & @CRLF & _ " --enable-ebcdic-nl25" & @CRLF & _ " --enable-never-backslash-C" & @CRLF & _ " --enable-pcre2-16" & @CRLF & _ " --enable-pcre2-32" & @CRLF & _ " --enable-pcre2grep-libbz2" & @CRLF & _ " --enable-pcre2grep-libz" & @CRLF & _ " --enable-pcre2test-libedit" & @CRLF & _ " --enable-pcre2test-libreadline" & @CRLF & _ " --entityPath" & @CRLF & _ " --expect100-timeout" & @CRLF & _ " --exportedData" & @CRLF & _ " --filter-A" & @CRLF & _ " --filter-AAAA" & @CRLF & _ " --filterwin2k" & @CRLF & _ " --force-ipv4" & @CRLF & _ " --force-ipv6" & @CRLF & _ " --force-R5" & @CRLF & _ " --force-V4" & @CRLF & _ " --Foreground" & @CRLF & _ " --fwdownload-mode3" & @CRLF & _ " --fwdownload-mode3-max" & @CRLF & _ " --fwdownload-mode7" & @CRLF & _ " --gb18030" & @CRLF & _ " --GBR" & @CRLF & _ " --hostpubmd5" & @CRLF & _ " --hostpubsha256" & @CRLF & _ " --http0" & @CRLF & _ " --http1" & @CRLF & _ " --http2" & @CRLF & _ " --http2-prior-knowledge" & @CRLF & _ " --http3" & @CRLF & _ " --http3-only" & @CRLF & _ " --ignoreDefinites" & @CRLF & _ " --importData" & @CRLF & _ " --Include" & @CRLF & _ " --intra_dc_prec" & @CRLF & _ " --ip6" & @CRLF & _ " --ip6-destination" & @CRLF & _ " --ip6-destination-port" & @CRLF & _ " --ip6-dport" & @CRLF & _ " --ip6-dst" & @CRLF & _ " --ip6-icmp-type" & @CRLF & _ " --ip6-proto" & @CRLF & _ " --ip6-protocol" & @CRLF & _ " --ip6-source" & @CRLF & _ " --ip6-source-port" & @CRLF & _ " --ip6-sport" & @CRLF & _ " --ip6-src" & @CRLF & _ " --ip6-tclass" & @CRLF & _ " --ipv4" & @CRLF & _ " --ipv6" & @CRLF & _ " --Iraw" & @CRLF & _ " --Istdin" & @CRLF & _ " --Istdout" & @CRLF & _ " --jsonPolicy" & @CRLF & _ " --keep-utf16" & @CRLF & _ " --keyPath" & @CRLF & _ " --lang_exclude" & @CRLF & _ " --Lc" & @CRLF & _ " --Lee" & @CRLF & _ " --linearize-pass1" & @CRLF & _ " --Lmac2" & @CRLF & _ " --Ln" & @CRLF & _ " --logData" & @CRLF & _ " --log-ip6" & @CRLF & _ " --Lx" & @CRLF & _ " --mirror-above-4G" & @CRLF & _ " --mirror-below-4G" & @CRLF & _ " --netfilter6" & @CRLF & _ " --no-0x20-encode" & @CRLF & _ " --no3d" & @CRLF & _ " --no-altscan-mpeg2" & @CRLF & _ " --no-D" & @CRLF & _ " --no-dhcpv4-interface" & @CRLF & _ " --no-dummy-svcd-SOF" & @CRLF & _ " --nr_methods" & @CRLF & _ " --numBytes" & @CRLF & _ " --Numeric" & @CRLF & _ " --nvPath" & @CRLF & _ " --oauth2-bearer" & @CRLF & _ " --omit_journal_replay" & @CRLF & _ " --output-Z1" & @CRLF & _ " --output-Z2" & @CRLF & _ " --p12-charset" & @CRLF & _ " --pathList" & @CRLF & _ " --pathOfKeyToDuplicate" & @CRLF & _ " --pcrIndex" & @CRLF & _ " --pcrList" & @CRLF & _ " --pcrLog" & @CRLF & _ " --pcrValue" & @CRLF & _ " --plainText" & @CRLF & _ " --policyPath" & @CRLF & _ " --policyRef" & @CRLF & _ " --post301" & @CRLF & _ " --post302" & @CRLF & _ " --post303" & @CRLF & _ " --prefer-ata12" & @CRLF & _ " --print0" & @CRLF & _ " --PROG-option" & @CRLF & _ " --proxy1" & @CRLF & _ " --proxy-http2" & @CRLF & _ " --proxy-tls13-ciphers" & @CRLF & _ " --proxy-tlsv1" & @CRLF & _ " --publicKey" & @CRLF & _ " --publicKeyPath" & @CRLF & _ " --qualifyingData" & @CRLF & _ " --quiet-dhcp6" & @CRLF & _ " --quoteInfo" & @CRLF & _ " --readimpliesX" & @CRLF & _ " --reduction-2x2" & @CRLF & _ " --reduction-4x4" & @CRLF & _ " --replay_journal_only" & @CRLF & _ " --searchPath" & @CRLF & _ " --seek_bytes" & @CRLF & _ " --set-recommended-min_free_kbytes" & @CRLF & _ " --S-force" & @CRLF & _ " --size_bytes" & @CRLF & _ " --socks4" & @CRLF & _ " --socks4a" & @CRLF & _ " --socks5" & @CRLF & _ " --socks5-basic" & @CRLF & _ " --socks5-gssapi" & @CRLF & _ " --socks5-gssapi-nec" & @CRLF & _ " --socks5-gssapi-service" & @CRLF & _ " --socks5-hostname" & @CRLF & _ " --sslv2" & @CRLF & _ " --sslv3" & @CRLF & _ " --tls13-ciphers" & @CRLF & _ " --tlsv1" & @CRLF & _ " --tpm2" & @CRLF & _ " --tpm2bPrivate" & @CRLF & _ " --tpm2bPublic" & @CRLF & _ " --type_trans" & @CRLF & _ " --type_transition" & @CRLF & _ " --UCS-2" & @CRLF & _ " --Version" & @CRLF & _ " --warning-exit-0" & @CRLF & _ " --Wext" & @CRLF & _ " --with-pcre2grep-bufsize" & @CRLF & _ " --with-pcre2grep-max-bufsize" & @CRLF & _ " --with-PROG" & @CRLF & _ " --Wnp" & @CRLF & _ " --Wp" & @CRLF & _ " --x11" & @CRLF & _ " --x32" & @CRLF & _ " --x509certData" 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