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

/
/
g

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 = "\/\*[\s\S]*?\*\/" Local $sString = "var ExecutionScript = (function () {" & @CRLF & _ " function ExecutionScript() {" & @CRLF & _ " }" & @CRLF & _ " ExecutionScript.prototype.RemoveSchemes = function (e) {" & @CRLF & _ " var _this = this;" & @CRLF & _ " debugger;" & @CRLF & _ " return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {" & @CRLF & _ " var selectedRole, currentSchemes, schemesToRemove, tempSchemes, filteredSchemes, _loop_1, newSchemes, _i, schemesToRemove_1, selectedScheme, _a, _b, scheme_1, newSchemes, _c, newSchemes_1, s;" & @CRLF & _ " return __generator(this, function (_d) {" & @CRLF & _ " switch (_d.label) {" & @CRLF & _ " case 0://test" & @CRLF & _ " selectedRole = e.data.Role_Variable.currentItem.Role.currentItem;" & @CRLF & _ " currentSchemes = selectedRole.Scheme.value;" & @CRLF & _ " schemesToRemove = e.plugins.Schemes_From_Data_Grid.SelectedItems;" & @CRLF & _ " tempSchemes = e.data.Temp_Role_Variable.currentItem.Scheme;" & @CRLF & _ " _loop_1 = function (selectedScheme) {" & @CRLF & _ " var _i, filteredSchemes_1, scheme, _a, newSchemes_2, s;" & @CRLF & _ " return __generator(this, function (_b) {" & @CRLF & _ " switch (_b.label) {" & @CRLF & _ " case 0:" & @CRLF & _ " filteredSchemes = currentSchemes.filter(function (scheme) { return scheme.ID !== selectedScheme.ID; });" & @CRLF & _ " _i = 0, filteredSchemes_1 = filteredSchemes;" & @CRLF & _ " _b.label = 1;/*" & @CRLF & _ " * testing multline comment" & @CRLF & _ " " & @CRLF & _ " */case 1:" & @CRLF & _ " if (!(_i < filteredSchemes_1.length)) return [3 /*break*/, 4];" & @CRLF & _ " scheme = filteredSchemes_1[_i];/*" & @CRLF & _ " * testing multline comment" & @CRLF & _ " */" & @CRLF & _ " return [4 /*yield*/, tempSchemes.create(1, false, e.data.Temp_Role_Variable.currentItem)];" & @CRLF & _ " case 2:" & @CRLF & _ "" & @CRLF & _ " /*" & @CRLF & _ "" & @CRLF & _ " * testing multline comment" & @CRLF & _ " */" & @CRLF & _ " newSchemes = _b.sent();" & @CRLF & _ " for (_a = 0, newSchemes_2 = newSchemes; _a < newSchemes_2.length; _a++) {" & @CRLF & _ " s = newSchemes_2[_a];" & @CRLF & _ " s.Active = scheme.Active;" & @CRLF & _ " s.Description = scheme.Description;" & @CRLF & _ " s.DisplayName = scheme.DisplayName;" & @CRLF & _ " s.Name = scheme.Name;" & @CRLF & _ " s.Role = scheme.Role;" & @CRLF & _ " s.SchemeId = scheme.SchemeId;" & @CRLF & _ " }" & @CRLF & _ " debugger;" & @CRLF & _ " tempSchemes.addItems(newSchemes);" & @CRLF & _ " _b.label = 3;" & @CRLF & _ " case 3://" & @CRLF & _ " _i++;" & @CRLF & _ " return [3 /*break*/, 1];" & @CRLF & _ " case 4: return [2 /*return*/];" & @CRLF & _ " }" & @CRLF & _ " });" & @CRLF & _ " };//" & @CRLF & _ " _i = 0, schemesToRemove_1 = schemesToRemove;" & @CRLF & _ " _d.label = 1;" & @CRLF & _ " case 1:" & @CRLF & _ " if (!(_i < schemesToRemove_1.length)) return [3 /*break*/, 4];" & @CRLF & _ " selectedScheme = schemesToRemove_1[_i];" & @CRLF & _ " return [5 /*yield**/, _loop_1(selectedScheme)];" & @CRLF & _ " case 2:" & @CRLF & _ " _d.sent();" & @CRLF & _ " _d.label = 3;" & @CRLF & _ " case 3:" & @CRLF & _ " _i++;" & @CRLF & _ " return [3 /*break*/, 1];" & @CRLF & _ " case 4:" & @CRLF & _ " // }" & @CRLF & _ " selectedRole.Scheme.clear();" & @CRLF & _ " _a = 0, _b = tempSchemes.value;" & @CRLF & _ " _d.label = 5;" & @CRLF & _ " case 5:" & @CRLF & _ " if (!(_a < _b.length)) return [3 /*break*/, 8];" & @CRLF & _ " scheme_1 = _b[_a];" & @CRLF & _ " return [4 /*yield*/, selectedRole.Scheme.create(1, false, e.data.Role_Variable.currentItem)];" & @CRLF & _ " case 6:" & @CRLF & _ " newSchemes = _d.sent();" & @CRLF & _ " for (_c = 0, newSchemes_1 = newSchemes; _c < newSchemes_1.length; _c++) {" & @CRLF & _ " s = newSchemes_1[_c];" & @CRLF & _ " s.Active = scheme_1.Active;" & @CRLF & _ " s.Description = scheme_1.Description;" & @CRLF & _ " s.DisplayName = scheme_1.DisplayName;" & @CRLF & _ " s.Name = scheme_1.Name;" & @CRLF & _ " s.Role = scheme_1.Role;" & @CRLF & _ " s.SchemeId = scheme_1.SchemeId;" & @CRLF & _ " }" & @CRLF & _ " selectedRole.Scheme.addItems(newSchemes);" & @CRLF & _ " _d.label = 7;" & @CRLF & _ " case 7:" & @CRLF & _ " _a++;" & @CRLF & _ " return [3 /*break*/, 5];" & @CRLF & _ " case 8:" & @CRLF & _ " e.data.Role_Variable.currentItem;" & @CRLF & _ " selectedRole.ConfiguredStatus = 'Complete';" & @CRLF & _ " resolve();" & @CRLF & _ " return [2 /*return*/];" & @CRLF & _ " }" & @CRLF & _ " });" & @CRLF & _ " }); });" & @CRLF & _ " };" & @CRLF & _ " ExecutionScript.prototype.S_On_Previous = function (e) {" & @CRLF & _ " e.data.currentUser.currentItem.Role.clear();" & @CRLF & _ " };" & @CRLF & _ " return ExecutionScript;" & @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