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

/
/
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\S]*?\*\/|([^:]|^)\/\/.*$" Local $sString = "/*!" & @CRLF & _ " * jQuery JavaScript Library v3.6.0" & @CRLF & _ " * https://jquery.com/" & @CRLF & _ " *" & @CRLF & _ " * Includes Sizzle.js" & @CRLF & _ " * https://sizzlejs.com/" & @CRLF & _ " *" & @CRLF & _ " * Copyright OpenJS Foundation and other contributors" & @CRLF & _ " * Released under the MIT license" & @CRLF & _ " * https://jquery.org/license" & @CRLF & _ " *" & @CRLF & _ " * Date: 2021-03-02T17:08Z" & @CRLF & _ " */" & @CRLF & _ "//hellow orld" & @CRLF & _ "( function( global, factory ) {" & @CRLF & _ "/*" & @CRLF & _ "Hell world" & @CRLF & _ "*/" & @CRLF & _ " "use strict";" & @CRLF & _ "" & @CRLF & _ " if ( typeof module === "object" && typeof module.exports === "object" ) {" & @CRLF & _ "" & @CRLF & _ " // For CommonJS and CommonJS-like environments where a proper `window`" & @CRLF & _ " // is present, execute the factory and get jQuery." & @CRLF & _ " // For environments that do not have a `window` with a `document`" & @CRLF & _ " // (such as Node.js), expose a factory as module.exports." & @CRLF & _ " // This accentuates the need for the creation of a real `window`." & @CRLF & _ " // e.g. var jQuery = require("jquery")(window);" & @CRLF & _ " // See ticket #14549 for more info." & @CRLF & _ " module.exports = global.document ?" & @CRLF & _ " factory( global, true ) :" & @CRLF & _ " function( w ) {" & @CRLF & _ " if ( !w.document ) {" & @CRLF & _ " throw new Error( "jQuery requires a window with a document https://jquery.org/license" );" & @CRLF & _ " }" & @CRLF & _ " return factory( w );" & @CRLF & _ " };" & @CRLF & _ " } else {" & @CRLF & _ " factory( global );" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ "// Pass this if window is not defined yet" & @CRLF & _ "} )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {" & @CRLF & _ "" & @CRLF & _ "// Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1" & @CRLF & _ "// throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode" & @CRLF & _ "// arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common" & @CRLF & _ "// enough that all such attempts are guarded in a try block." & @CRLF & _ ""use strict";" & @CRLF & _ "" & @CRLF & _ "var arr = [];" & @CRLF & _ "" & @CRLF & _ "var getProto = Object.getPrototypeOf;" & @CRLF & _ "" & @CRLF & _ "var slice = arr.slice;" & @CRLF & _ "" & @CRLF & _ "var flat = arr.flat ? function( array ) {" & @CRLF & _ " return arr.flat.call( array );" & @CRLF & _ "} : function( array ) {" & @CRLF & _ " return arr.concat.apply( [], array );" & @CRLF & _ "};" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "var push = arr.push;" & @CRLF & _ "" & @CRLF & _ "var indexOf = arr.indexOf;" & @CRLF & _ "" & @CRLF & _ "var class2type = {};" & @CRLF & _ "" & @CRLF & _ "var toString = class2type.toString;" & @CRLF & _ "" & @CRLF & _ "var hasOwn = class2type.hasOwnProperty;" & @CRLF & _ "" & @CRLF & _ "var fnToString = hasOwn.toString;" & @CRLF & _ "" & @CRLF & _ "var ObjectFunctionString = fnToString.call( Object );" & @CRLF & _ "" & @CRLF & _ "var support = {};" & @CRLF & _ "" & @CRLF & _ "var isFunction = function isFunction( obj ) {" & @CRLF & _ "" & @CRLF & _ " // Support: Chrome <=57, Firefox <=52" & @CRLF & _ " // In some browsers, typeof returns "function" for HTML <object> elements" & @CRLF & _ " // (i.e., `typeof document.createElement( "object" ) === "function"`)." & @CRLF & _ " // We don't want to classify *any* DOM node as a function." & @CRLF & _ " // Support: QtWeb <=3.8.5, WebKit <=534.34, wkhtmltopdf tool <=0.12.5" & @CRLF & _ " // Plus for old WebKit, typeof returns "function" for HTML collections" & @CRLF & _ " // (e.g., `typeof document.getElementsByTagName("div") === "function"`). (gh-4756)" & @CRLF & _ " return typeof obj === "function" && typeof obj.nodeType !== "number" &&" & @CRLF & _ " typeof obj.item !== "function";" & @CRLF & _ " };" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "var isWindow = function isWindow( obj ) {" & @CRLF & _ " return obj != null && obj === obj.window;" & @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