Regular Expressions 101

Save & Manage Regex

  • Current Version: 1
  • Save & Share
  • Community Library

Flavor

  • PCRE2 (PHP)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java
  • .NET 7.0 (C#)
  • Rust
  • PCRE (Legacy)
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests
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
Processing...

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 = "(?:\$|jQuery)\.mage\.__\((?s)[^'"]*?(['"])(.+?)(?<!\\)\1(?s).*?\)" Local $sString = "/**" & @CRLF & _ " * Copyright © 2013-2017 Magento, Inc. All rights reserved." & @CRLF & _ " * See COPYING.txt for license details." & @CRLF & _ " */" & @CRLF & _ "" & @CRLF & _ "define([" & @CRLF & _ " 'jquery'," & @CRLF & _ " 'ko'," & @CRLF & _ " 'module'," & @CRLF & _ " '../template/renderer'," & @CRLF & _ " 'mage/translate'" & @CRLF & _ "], function ($, ko, module, renderer) {" & @CRLF & _ " 'use strict';" & @CRLF & _ "" & @CRLF & _ " var locations = {" & @CRLF & _ " 'legend': 'Caption for the fieldset element'," & @CRLF & _ " 'label': 'Label for an input element.'," & @CRLF & _ " 'button': 'Push button'," & @CRLF & _ " 'a': 'Link label'," & @CRLF & _ " 'b': 'Bold text'," & @CRLF & _ " 'strong': 'Strong emphasized text'," & @CRLF & _ " 'i': 'Italic text'," & @CRLF & _ " 'em': 'Emphasized text'," & @CRLF & _ " 'u': 'Underlined text'," & @CRLF & _ " 'sup': 'Superscript text'," & @CRLF & _ " 'sub': 'Subscript text'," & @CRLF & _ " 'span': 'Span element'," & @CRLF & _ " 'small': 'Smaller text'," & @CRLF & _ " 'big': 'Bigger text'," & @CRLF & _ " 'address': 'Contact information'," & @CRLF & _ " 'blockquote': 'Long quotation'," & @CRLF & _ " 'q': 'Short quotation'," & @CRLF & _ " 'cite': 'Citation'," & @CRLF & _ " 'caption': 'Table caption'," & @CRLF & _ " 'abbr': 'Abbreviated phrase'," & @CRLF & _ " 'acronym': 'An acronym'," & @CRLF & _ " 'var': 'Variable part of a text'," & @CRLF & _ " 'dfn': 'Term'," & @CRLF & _ " 'strike': 'Strikethrough text'," & @CRLF & _ " 'del': 'Deleted text'," & @CRLF & _ " 'ins': 'Inserted text'," & @CRLF & _ " 'h1': 'Heading level 1'," & @CRLF & _ " 'h2': 'Heading level 2'," & @CRLF & _ " 'h3': 'Heading level 3'," & @CRLF & _ " 'h4': 'Heading level 4'," & @CRLF & _ " 'h5': 'Heading level 5'," & @CRLF & _ " 'h6': 'Heading level 6'," & @CRLF & _ " 'center': 'Centered text'," & @CRLF & _ " 'select': 'List options'," & @CRLF & _ " 'img': 'Image'," & @CRLF & _ " 'input': 'Form element'" & @CRLF & _ " }," & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Generates [data-translate] attribute's value" & @CRLF & _ " * @param {Object} translationData" & @CRLF & _ " * @param {String} location" & @CRLF & _ " */" & @CRLF & _ " composeTranslateAttr = function (translationData, location) {" & @CRLF & _ " var obj = [{" & @CRLF & _ " 'shown': translationData.shown," & @CRLF & _ " 'translated': translationData.translated," & @CRLF & _ " 'original': translationData.original," & @CRLF & _ " 'location': locations[location] || 'Text'" & @CRLF & _ " }];" & @CRLF & _ "" & @CRLF & _ " return JSON.stringify(obj);" & @CRLF & _ " }," & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Sets text for the element" & @CRLF & _ " * @param {Object} el" & @CRLF & _ " * @param {String} text" & @CRLF & _ " */" & @CRLF & _ " setText = function (el, text) {" & @CRLF & _ " $(el).text(text);" & @CRLF & _ " }," & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Sets [data-translate] attribute for the element" & @CRLF & _ " * @param {Object} el - The element which is binded" & @CRLF & _ " * @param {String} original - The original value of the element" & @CRLF & _ " */" & @CRLF & _ " setTranslateProp = function (el, original) {" & @CRLF & _ " var location = $(el).prop('tagName').toLowerCase()," & @CRLF & _ " translated = $.mage.__(original)," & @CRLF & _ " translationData = {" & @CRLF & _ " shown: translated," & @CRLF & _ " translated: translated," & @CRLF & _ " original: original" & @CRLF & _ " }," & @CRLF & _ " translateAttr = composeTranslateAttr(translationData, location);" & @CRLF & _ "" & @CRLF & _ " $(el).attr('data-translate', translateAttr);" & @CRLF & _ "" & @CRLF & _ " setText(el, translationData.shown);" & @CRLF & _ " }," & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Checks if node represents ko virtual node (nodeType === 8, nodeName === '#comment')." & @CRLF & _ " *" & @CRLF & _ " * @param {HTMLElement} node" & @CRLF & _ " * @returns {Boolean}" & @CRLF & _ " */" & @CRLF & _ " isVirtualElement = function (node) {" & @CRLF & _ " return node.nodeType === 8;" & @CRLF & _ " }," & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Checks if it's real DOM element" & @CRLF & _ " * in case of virtual element, returns span wrapper" & @CRLF & _ " * @param {Object} el" & @CRLF & _ " * @param {bool} isUpdate" & @CRLF & _ " * @return {Object} el" & @CRLF & _ " */" & @CRLF & _ " getRealElement = function (el, isUpdate) {" & @CRLF & _ " if (isVirtualElement(el)) {" & @CRLF & _ " if (isUpdate) {" & @CRLF & _ " return $(el).next('span');" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " return $('<span/>').insertAfter(el);" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " return el;" & @CRLF & _ " }," & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * execute i18n binding" & @CRLF & _ " * @param {Object} element" & @CRLF & _ " * @param {Function} valueAccessor" & @CRLF & _ " * @param {bool} isUpdate" & @CRLF & _ " */" & @CRLF & _ " execute = function (element, valueAccessor, isUpdate) {" & @CRLF & _ " var original = ko.unwrap(valueAccessor() || '')," & @CRLF & _ " el = getRealElement(element, isUpdate)," & @CRLF & _ " inlineTranslation = (module.config() || {}).inlineTranslation;" & @CRLF & _ "" & @CRLF & _ " if (inlineTranslation) {" & @CRLF & _ " setTranslateProp(el, original);" & @CRLF & _ " } else {" & @CRLF & _ " setText(el, $.mage.__(original));" & @CRLF & _ " }" & @CRLF & _ " };" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * i18n binding" & @CRLF & _ " * @property {Function} init" & @CRLF & _ " * @property {Function} update" & @CRLF & _ " */" & @CRLF & _ " ko.bindingHandlers.i18n = {" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * init i18n binding" & @CRLF & _ " * @param {Object} element" & @CRLF & _ " * @param {Function} valueAccessor" & @CRLF & _ " */" & @CRLF & _ " init: function (element, valueAccessor) {" & @CRLF & _ " execute(element, valueAccessor);" & @CRLF & _ " }," & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * update i18n binding" & @CRLF & _ " * @param {Object} element" & @CRLF & _ " * @param {Function} valueAccessor" & @CRLF & _ " */" & @CRLF & _ " update: function (element, valueAccessor) {" & @CRLF & _ " execute(element, valueAccessor, true);" & @CRLF & _ " }" & @CRLF & _ " };" & @CRLF & _ "" & @CRLF & _ " ko.virtualElements.allowedBindings.i18n = true;" & @CRLF & _ "" & @CRLF & _ " renderer" & @CRLF & _ " .addNode('translate', {" & @CRLF & _ " binding: 'i18n'" & @CRLF & _ " })" & @CRLF & _ " .addAttribute('translate', {" & @CRLF & _ " binding: 'i18n'" & @CRLF & _ " });" & @CRLF & _ "});" & @CRLF & _ "" Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYFULLMATCH) ; 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