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

/
/
mig

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 = "(?mi)['"]([^'"]*\.(css|js|less|sass|txt|csv|jpeg|jpg|bmp|png|gif|json))['"]" Local $sString = "var styleSwitcher = {" & @CRLF & _ " initialized: !1," & @CRLF & _ " defaults: {" & @CRLF & _ " saveToStorage: !0," & @CRLF & _ " preserveCookies: !1," & @CRLF & _ " colorPrimary: "#0088CC"," & @CRLF & _ " backgroundColor: "light"," & @CRLF & _ " headerColor: "light"," & @CRLF & _ " borderRadius: "4px"," & @CRLF & _ " layoutStyle: "wide"," & @CRLF & _ " sidebarColor: "dark"," & @CRLF & _ " sidebarSize: "md"," & @CRLF & _ " changeLogo: !0" & @CRLF & _ " }," & @CRLF & _ " initialize: function() {" & @CRLF & _ " var a = this," & @CRLF & _ " b = $("html").data("style-switcher-options");" & @CRLF & _ " this.initialized || (a.options = $.extend({}, a.defaults), String.prototype.capitalize = function() {" & @CRLF & _ " return this.charAt(0).toUpperCase() + this.slice(1)" & @CRLF & _ " }, jQuery.styleSwitcherCachedScript = function(a, b) {" & @CRLF & _ " return b = $.extend(b || {}, {" & @CRLF & _ " dataType: "script"," & @CRLF & _ " cache: !0," & @CRLF & _ " url: a" & @CRLF & _ " }), jQuery.ajax(b)" & @CRLF & _ " }, null != $.cookie("borderRadius") && (a.options.borderRadius = $.cookie("borderRadius")), null != $.cookie("colorPrimary") && (a.options.colorPrimary = "#" + $.cookie("colorPrimary")), b && (b = b.replace(/'/g, '"'), a.options = $.extend({}, a.options, JSON.parse(b)), a.options.preserveCookies = !0, a.options.saveToStorage = !1), $("head").append($('<link rel="stylesheet">').attr("href", "assets/vendor/style-switcher/style-switcher.css")), $("head").append($('<link rel="stylesheet/less">').attr("href", "assets/vendor/style-switcher/less/skin.less")), $("head").append($('<link rel="stylesheet/less">').attr("href", "assets/vendor/style-switcher/less/extension.less")), $("head").append($('<link rel="stylesheet">').attr("href", "assets/vendor/style-switcher/bootstrap-colorpicker/css/bootstrap-colorpicker.css")), $.styleSwitcherCachedScript("assets/vendor/style-switcher/bootstrap-colorpicker/js/bootstrap-colorpicker.min.js").done(function(c, d) {" & @CRLF & _ " less = {" & @CRLF & _ " env: "production"," & @CRLF & _ " modifyVars: {" & @CRLF & _ " "@border-radius": a.options.borderRadius," & @CRLF & _ " "@color-primary": a.options.colorPrimary" & @CRLF & _ " }" & @CRLF & _ " }, $.styleSwitcherCachedScript("assets/vendor/less/less.min.js").done(function(c, d) {" & @CRLF & _ " $.ajax({" & @CRLF & _ " url: "assets/vendor/style-switcher/style.switcher.html"" & @CRLF & _ " }).done(function(c) {" & @CRLF & _ " $("body").append(c), a.container = $("#styleSwitcher"), a.build(), a.events(), b || (null != $.cookie("layoutStyle") && (a.options.layoutStyle = $.cookie("layoutStyle")), null != $.cookie("backgroundColor") && (a.options.backgroundColor = $.cookie("backgroundColor")), null != $.cookie("headerColor") && (a.options.headerColor = $.cookie("headerColor")), null != $.cookie("sidebarColor") && (a.options.sidebarColor = $.cookie("sidebarColor")), null != $.cookie("sidebarSize") && (a.options.sidebarSize = $.cookie("sidebarSize"))), a.setLayoutStyle(a.options.layoutStyle), a.setBackgroundColor(a.options.backgroundColor), a.setHeaderColor(a.options.headerColor), a.setSidebarColor(a.options.sidebarColor), a.setSidebarSize(a.options.sidebarSize), a.setColors(), a.setBorderRadius(a.options.borderRadius), null == $.cookie("initialized") && (a.container.find("#styleSwitcherOpen").click(), $.cookie("initialized", !0)), a.initialized = !0" & @CRLF & _ " })" & @CRLF & _ " })" & @CRLF & _ " }), $.styleSwitcherCachedScript("assets/vendor/style-switcher/cssbeautify/cssbeautify.js").done(function(a, b) {}))" & @CRLF & _ " }," & @CRLF & _ " build: function() {" & @CRLF & _ " var a = this," & @CRLF & _ " b = a.container.find(".color-primary input");" & @CRLF & _ " b.val(a.options.colorPrimary).parent().colorpicker({" & @CRLF & _ " align: "right"," & @CRLF & _ " customClass: "style-switcher-color-picker"" & @CRLF & _ " }), $(".colorpicker").on("mousedown", function(b) {" & @CRLF & _ " b.preventDefault(), a.isChanging = !0" & @CRLF & _ " }).on("mouseup", function(c) {" & @CRLF & _ " c.preventDefault(), a.isChanging = !1, a.options.colorPrimary = b.val(), a.setColors()" & @CRLF & _ " }), $(".colorpicker-element input").on("blur", function(c) {" & @CRLF & _ " a.options.colorPrimary = b.val(), a.setColors()" & @CRLF & _ " }), this.container.find(".options-links.borders a").click(function(b) {" & @CRLF & _ " b.preventDefault(), a.setBorderRadius($(this).attr("data-border-radius"))" & @CRLF & _ " }), this.container.find(".options-links.background-color a").click(function(b) {" & @CRLF & _ " b.preventDefault(), a.setBackgroundColor($(this).attr("data-background-color"))" & @CRLF & _ " }), this.container.find(".options-links.header-color a").click(function(b) {" & @CRLF & _ " b.preventDefault(), a.setHeaderColor($(this).attr("data-header-color"))" & @CRLF & _ " }), this.container.find(".options-links.sidebar-color a").click(function(b) {" & @CRLF & _ " b.preventDefault(), a.setSidebarColor($(this).attr("data-sidebar-color"))" & @CRLF & _ " }), this.container.find(".options-links.layout a").click(function(b) {" & @CRLF & _ " b.preventDefault(), a.setLayoutStyle($(this).attr("data-layout-type"))" & @CRLF & _ " }), this.container.find(".options-links.sidebar-size a").click(function(b) {" & @CRLF & _ " b.preventDefault(), a.setSidebarSize($(this).attr("data-sidebar-size"))" & @CRLF & _ " }), a.container.find(".reset").click(function(b) {" & @CRLF & _ " b.preventDefault(), a.reset()" & @CRLF & _ " }), a.container.find(".get-css").click(function(b) {" & @CRLF & _ " b.preventDefault(), a.getCss()" & @CRLF & _ " })" & @CRLF & _ " }," & @CRLF & _ " events: function() {" & @CRLF & _ " var a = this;" & @CRLF & _ " $("#styleSwitcherOpen").click(function(b) {" & @CRLF & _ " b.preventDefault(), a.container.hasClass("active") ? a.container.animate({" & @CRLF & _ " right: "-" + a.container.width() + "px"" & @CRLF & _ " }, 300).removeClass("active") : a.container.animate({" & @CRLF & _ " right: "0"" & @CRLF & _ " }, 300).addClass("active")" & @CRLF & _ " }), (null != $.cookie("showSwitcher") || $("body").hasClass("one-page")) && ($("#styleSwitcherOpen").click(), $.removeCookie("showSwitcher"))" & @CRLF & _ " }," & @CRLF & _ " setColors: function(a, b) {" & @CRLF & _ " var c = this;" & @CRLF & _ " return this.isChanging ? !1 : (a && (c.options["color" + b.capitalize()] = a, c.container.find(".color-" + b + " input").val(a)), c.options.preserveCookies || $.cookie("colorPrimary", c.options.colorPrimary.replace("#", "")), c.modifyVars(), void this.setLogo())" & @CRLF & _ " }," & @CRLF & _ " setBorderRadius: function(a) {" & @CRLF & _ " var b = this;" & @CRLF & _ " b.options.borderRadius = a, b.options.preserveCookies || $.cookie("borderRadius", a), b.modifyVars();" & @CRLF & _ " var c = this.container.find(".options-links.borders");" & @CRLF & _ " c.find(".active").removeClass("active"), c.find("a[data-border-radius=" + a + "]").addClass("active"), $.event.trigger({" & @CRLF & _ " type: "styleSwitcher.setBorderRadius"," & @CRLF & _ " radius: a" & @CRLF & _ " })" & @CRLF & _ " }," & @CRLF & _ " setBackgroundColor: function(a) {" & @CRLF & _ " var b = this;" & @CRLF & _ " b.options.preserveCookies || $.cookie("backgroundColor", a), this.options.saveToStorage && "undefined" != typeof localStorage && localStorage.setItem("backgroundColor", a);" & @CRLF & _ " var c = this.container.find(".options-links.background-color");" & @CRLF & _ " c.find(".active").removeClass("active"), c.find("a[data-background-color=" + a + "]").addClass("active"), "dark" == a ? ($("html").addClass("dark"), $("#addDarkClassInfo").show()) : ($("html").removeClass("dark"), $("#addDarkClassInfo").hide()), $.event.trigger({" & @CRLF & _ " type: "styleSwitcher.setBackgroundColor"," & @CRLF & _ " color: a" & @CRLF & _ " }), this.setLogo()" & @CRLF & _ " }," & @CRLF & _ " setHeaderColor: function(a) {" & @CRLF & _ " var b = this;" & @CRLF & _ " b.options.preserveCookies || $.cookie("headerColor", a), this.options.saveToStorage && "undefined" != typeof localStorage && localStorage.setItem("headerColor", a);" & @CRLF & _ " var c = this.container.find(".options-links.header-color");" & @CRLF & _ " c.find(".active").removeClass("active"), c.find("a[data-header-color=" + a + "]").addClass("active"), "dark" == a ? ($("html").addClass("header-dark"), $("#addHeaderDarkClassInfo").show()) : ($("html").removeClass("header-dark"), $("#addHeaderDarkClassInfo").hide()), $.event.trigger({" & @CRLF & _ " type: "styleSwitcher.setHeaderColor"," & @CRLF & _ " color: a" & @CRLF & _ " })" & @CRLF & _ " }," & @CRLF & _ " setSidebarColor: function(a) {" & @CRLF & _ " var b = this;" & @CRLF & _ " b.options.preserveCookies || $.cookie("sidebarColor", a), this.options.saveToStorage && "undefined" != typeof localStorage && localStorage.setItem("sidebarColor", a);" & @CRLF & _ " var c = this.container.find(".options-links.sidebar-color");" & @CRLF & _ " c.find(".active").removeClass("active"), c.find("a[data-sidebar-color=" + a + "]").addClass("active"), "light" == a ? ($("html").addClass("sidebar-light"), $("#addSidebarLightClassInfo").show()) : ($("html").removeClass("sidebar-light"), $("#addSidebarLightClassInfo").hide()), $.event.trigger({" & @CRLF & _ " type: "styleSwitcher.setSidebarColor"," & @CRLF & _ " color: a" & @CRLF & _ " })" & @CRLF & _ " }," & @CRLF & _ " setLayoutStyle: function(a, b) {" & @CRLF & _ " var c = this;" & @CRLF & _ " if (c.options.preserveCookies || $.cookie("layoutStyle", a), this.options.saveToStorage && "undefined" != typeof localStorage && localStorage.setItem("layout", a), b) return $.cookie("showSwitcher", !0), window.location.reload(), !1;" & @CRLF & _ " var d = this.container.find(".options-links.layout");" & @CRLF & _ " d.find(".active").removeClass("active"), d.find("a[data-layout-type=" + a + "]").addClass("active"), "wide" == a ? ($("html").removeClass("boxed"), $("#addBoxedClassInfo").hide()) : ($("html").addClass("boxed").removeClass("fixed"), $("#addBoxedClassInfo").show()), $.event.trigger({" & @CRLF & _ " type: "styleSwitcher.setLayoutStyle"," & @CRLF & _ " style: a" & @CRLF & _ " })" & @CRLF & _ " }," & @CRLF & _ " setSidebarSize: function(a) {" & @CRLF & _ " var b = this," & @CRLF & _ " c = $("html");" & @CRLF & _ " b.options.preserveCookies || $.cookie("sidebarSize", a), this.options.saveToStorage && "undefined" != typeof localStorage && localStorage.setItem("sidebarSize", a);" & @CRLF & _ " var d = this.container.find(".options-links.sidebar-size");" & @CRLF & _ " switch (d.find(".active").removeClass("active"), d.find("a[data-sidebar-size=" + a + "]").addClass("active"), c.removeClass("sidebar-left-xs sidebar-left-sm"), a) {" & @CRLF & _ " case "xs":" & @CRLF & _ " c.addClass("sidebar-left-xs");" & @CRLF & _ " break;" & @CRLF & _ " case "sm":" & @CRLF & _ " c.addClass("sidebar-left-sm")" & @CRLF & _ " }" & @CRLF & _ " $.event.trigger({" & @CRLF & _ " type: "styleSwitcher.setSidebarSize"," & @CRLF & _ " color: a" & @CRLF & _ " })" & @CRLF & _ " }," & @CRLF & _ " setLogo: function(a) {" & @CRLF & _ " if (!this.options.changeLogo) return this;" & @CRLF & _ " var b = $(".header .logo img, .center-sign .logo img");" & @CRLF & _ " a || ("#" + $.cookie("colorPrimary")).toUpperCase() == this.defaults.colorPrimary.toUpperCase() && "dark" != $.cookie("backgroundColor") ? b.attr("src", "assets/images/logo-default.png") : "dark" == $.cookie("backgroundColor") ? b.attr("src", "assets/images/logo-light.png") : b.attr("src", "assets/images/logo.png"), $.event.trigger({" & @CRLF & _ " type: "styleSwitcher.setLogo"" & @CRLF & _ " })" & @CRLF & _ " }," & @CRLF & _ " modifyVars: function() {" & @CRLF & _ " var a = this;" & @CRLF & _ " less.modifyVars({" & @CRLF & _ " "@border-radius": a.options.borderRadius," & @CRLF & _ " "@color-primary": a.options.colorPrimary" & @CRLF & _ " }), this.options.saveToStorage && "undefined" != typeof localStorage && localStorage.setItem("skin-admin.css", $('style[id^="less:"]').text()), $.event.trigger({" & @CRLF & _ " type: "styleSwitcher.modifyVars"," & @CRLF & _ " options: a.options" & @CRLF & _ " })" & @CRLF & _ " }," & @CRLF & _ " reset: function() {" & @CRLF & _ " $.removeCookie("borderRadius"), $.removeCookie("colorPrimary"), $.removeCookie("backgroundColor"), $.removeCookie("headerColor"), $.removeCookie("layoutStyle"), $.removeCookie("sidebarColor"), $.removeCookie("sidebarSize"), $.cookie("showSwitcher", !0), window.location.reload(), "undefined" != typeof localStorage && (localStorage.removeItem("skin-admin.css"), localStorage.removeItem("layout"))" & @CRLF & _ " }," & @CRLF & _ " getCss: function() {" & @CRLF & _ " var a = ""," & @CRLF & _ " b = "";" & @CRLF & _ " $("#getCSSTextarea").text($('style[id$="less-skin"]').text()).focus(function() {" & @CRLF & _ " var a = $(this);" & @CRLF & _ " a.select(), a.mouseup(function() {" & @CRLF & _ " return a.unbind("mouseup"), !1" & @CRLF & _ " })" & @CRLF & _ " }), a = $("#getCSSTextarea").text(), $("#getCSSTextarea").text(cssbeautify(a, {" & @CRLF & _ " indent: " "," & @CRLF & _ " autosemicolon: !0" & @CRLF & _ " })), $("#getCSSTextareaExtension").text($('style[id$="less-extension"]').text()).focus(function() {" & @CRLF & _ " var a = $(this);" & @CRLF & _ " a.select(), a.mouseup(function() {" & @CRLF & _ " return a.unbind("mouseup"), !1" & @CRLF & _ " })" & @CRLF & _ " }), b = $("#getCSSTextareaExtension").text(), $("#getCSSTextareaExtension").text(cssbeautify(b, {" & @CRLF & _ " indent: " "," & @CRLF & _ " autosemicolon: !0" & @CRLF & _ " })), $("#getCSSModal").modal("show")" & @CRLF & _ " }" & @CRLF & _ "};" & @CRLF & _ "styleSwitcher.initialize();" 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