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*([\w -_]+);" Local $sString = ":root {" & @CRLF & _ " --pf-global--palette--black-100: #fafafa;" & @CRLF & _ " --pf-global--palette--black-150: #f5f5f5;" & @CRLF & _ " --pf-global--palette--black-200: #ededed;" & @CRLF & _ " --pf-global--palette--black-300: #d2d2d2;" & @CRLF & _ " --pf-global--palette--black-400: #b8bbbe;" & @CRLF & _ " --pf-global--palette--black-500: #8a8d90;" & @CRLF & _ " --pf-global--palette--black-600: #737679;" & @CRLF & _ " --pf-global--palette--black-700: #4f5255;" & @CRLF & _ " --pf-global--palette--black-800: #3c3f42;" & @CRLF & _ " --pf-global--palette--black-850: #212427;" & @CRLF & _ " --pf-global--palette--black-900: #151515;" & @CRLF & _ " --pf-global--palette--black-1000: #030303;" & @CRLF & _ " --pf-global--palette--blue-50: #def3ff;" & @CRLF & _ " --pf-global--palette--blue-100: #bee1f4;" & @CRLF & _ " --pf-global--palette--blue-200: #73bcf7;" & @CRLF & _ " --pf-global--palette--blue-300: #2b9af3;" & @CRLF & _ " --pf-global--palette--blue-400: #06c;" & @CRLF & _ " --pf-global--palette--blue-500: #004080;" & @CRLF & _ " --pf-global--palette--blue-600: #004368;" & @CRLF & _ " --pf-global--palette--blue-700: #002235;" & @CRLF & _ " --pf-global--palette--cyan-100: #a2d9d9;" & @CRLF & _ " --pf-global--palette--cyan-200: #73c5c5;" & @CRLF & _ " --pf-global--palette--cyan-300: #009596;" & @CRLF & _ " --pf-global--palette--cyan-400: #005f60;" & @CRLF & _ " --pf-global--palette--cyan-500: #003737;" & @CRLF & _ " --pf-global--palette--cyan-600: #003d44;" & @CRLF & _ " --pf-global--palette--cyan-700: #001f22;" & @CRLF & _ " --pf-global--palette--gold-100: #f9e0a2;" & @CRLF & _ " --pf-global--palette--gold-200: #f6d173;" & @CRLF & _ " --pf-global--palette--gold-300: #f4c145;" & @CRLF & _ " --pf-global--palette--gold-400: #f0ab00;" & @CRLF & _ " --pf-global--palette--gold-500: #c58c00;" & @CRLF & _ " --pf-global--palette--gold-600: #795600;" & @CRLF & _ " --pf-global--palette--gold-700: #3d2c00;" & @CRLF & _ " --pf-global--palette--green-100: #bde5b8;" & @CRLF & _ " --pf-global--palette--green-200: #95d58e;" & @CRLF & _ " --pf-global--palette--green-300: #6ec664;" & @CRLF & _ " --pf-global--palette--green-400: #5ba352;" & @CRLF & _ " --pf-global--palette--green-500: #467f40;" & @CRLF & _ " --pf-global--palette--green-600: #1e4f18;" & @CRLF & _ " --pf-global--palette--green-700: #0f280d;" & @CRLF & _ " --pf-global--palette--light-blue-100: #beedf9;" & @CRLF & _ " --pf-global--palette--light-blue-200: #7cdbf3;" & @CRLF & _ " --pf-global--palette--light-blue-300: #35caed;" & @CRLF & _ " --pf-global--palette--light-blue-400: #00b9e4;" & @CRLF & _ " --pf-global--palette--light-blue-500: #008bad;" & @CRLF & _ " --pf-global--palette--light-blue-600: #005c73;" & @CRLF & _ " --pf-global--palette--light-blue-700: #002d39;" & @CRLF & _ " --pf-global--palette--light-green-100: #e4f5bc;" & @CRLF & _ " --pf-global--palette--light-green-200: #c8eb79;" & @CRLF & _ " --pf-global--palette--light-green-300: #ace12e;" & @CRLF & _ " --pf-global--palette--light-green-400: #92d400;" & @CRLF & _ " --pf-global--palette--light-green-500: #6ca100;" & @CRLF & _ " --pf-global--palette--light-green-600: #486b00;" & @CRLF & _ " --pf-global--palette--light-green-700: #253600;" & @CRLF & _ " --pf-global--palette--orange-100: #f4b678;" & @CRLF & _ " --pf-global--palette--orange-200: #ef9234;" & @CRLF & _ " --pf-global--palette--orange-300: #ec7a08;" & @CRLF & _ " --pf-global--palette--orange-400: #c46100;" & @CRLF & _ " --pf-global--palette--orange-500: #8f4700;" & @CRLF & _ " --pf-global--palette--orange-600: #773d00;" & @CRLF & _ " --pf-global--palette--orange-700: #3b1f00;" & @CRLF & _ " --pf-global--palette--purple-100: #cbc1ff;" & @CRLF & _ " --pf-global--palette--purple-200: #b2a3ff;" & @CRLF & _ " --pf-global--palette--purple-300: #a18fff;" & @CRLF & _ " --pf-global--palette--purple-400: #8476d1;" & @CRLF & _ " --pf-global--palette--purple-500: #6753ac;" & @CRLF & _ " --pf-global--palette--purple-600: #40199a;" & @CRLF & _ " --pf-global--palette--purple-700: #1f0066;" & @CRLF & _ " --pf-global--palette--red-100: #c9190b;" & @CRLF & _ " --pf-global--palette--red-200: #a30000;" & @CRLF & _ " --pf-global--palette--red-300: #7d1007;" & @CRLF & _ " --pf-global--palette--red-400: #470000;" & @CRLF & _ " --pf-global--palette--red-500: #2c0000;" & @CRLF & _ " --pf-global--palette--white: #fff;" & @CRLF & _ " --pf-global--BackgroundColor--100: #fff;" & @CRLF & _ " --pf-global--BackgroundColor--150: #f5f5f5;" & @CRLF & _ " --pf-global--BackgroundColor--200: #fafafa;" & @CRLF & _ " --pf-global--BackgroundColor--300: #ededed;" & @CRLF & _ " --pf-global--BackgroundColor--light-100: #fff;" & @CRLF & _ " --pf-global--BackgroundColor--light-200: #fafafa;" & @CRLF & _ " --pf-global--BackgroundColor--light-300: #ededed;" & @CRLF & _ " --pf-global--BackgroundColor--dark-100: #151515;" & @CRLF & _ " --pf-global--BackgroundColor--dark-200: #3c3f42;" & @CRLF & _ " --pf-global--BackgroundColor--dark-300: #212427;" & @CRLF & _ " --pf-global--BackgroundColor--dark-400: #4f5255;" & @CRLF & _ " --pf-global--BackgroundColor--dark-transparent-100: rgba(3, 3, 3, 0.62);" & @CRLF & _ " --pf-global--BackgroundColor--dark-transparent-200: rgba(3, 3, 3, 0.32);" & @CRLF & _ " --pf-global--Color--100: #151515;" & @CRLF & _ " --pf-global--Color--200: #737679;" & @CRLF & _ " --pf-global--Color--300: #3c3f42;" & @CRLF & _ " --pf-global--Color--400: #8a8d90;" & @CRLF & _ " --pf-global--Color--light-100: #fff;" & @CRLF & _ " --pf-global--Color--light-200: #ededed;" & @CRLF & _ " --pf-global--Color--light-300: #d2d2d2;" & @CRLF & _ " --pf-global--Color--dark-100: #151515;" & @CRLF & _ " --pf-global--Color--dark-200: #737679;" & @CRLF & _ " --pf-global--active-color--100: #06c;" & @CRLF & _ " --pf-global--active-color--200: #bee1f4;" & @CRLF & _ " --pf-global--active-color--300: #73bcf7;" & @CRLF & _ " --pf-global--active-color--400: #2b9af3;" & @CRLF & _ " --pf-global--disabled-color--100: #737679;" & @CRLF & _ " --pf-global--disabled-color--200: #d2d2d2;" & @CRLF & _ " --pf-global--disabled-color--300: #ededed;" & @CRLF & _ " --pf-global--primary-color--100: #06c;" & @CRLF & _ " --pf-global--primary-color--200: #004080;" & @CRLF & _ " --pf-global--primary-color--light-100: #73bcf7;" & @CRLF & _ " --pf-global--primary-color--dark-100: #06c;" & @CRLF & _ " --pf-global--secondary-color--100: #737679;" & @CRLF & _ " --pf-global--default-color--100: #73c5c5;" & @CRLF & _ " --pf-global--default-color--200: #009596;" & @CRLF & _ " --pf-global--default-color--300: #003737;" & @CRLF & _ " --pf-global--success-color--100: #92d400;" & @CRLF & _ " --pf-global--success-color--200: #486b00;" & @CRLF & _ " --pf-global--info-color--100: #73bcf7;" & @CRLF & _ " --pf-global--info-color--200: #004368;" & @CRLF & _ " --pf-global--warning-color--100: #f0ab00;" & @CRLF & _ " --pf-global--warning-color--200: #795600;" & @CRLF & _ " --pf-global--danger-color--100: #c9190b;" & @CRLF & _ " --pf-global--danger-color--200: #a30000;" & @CRLF & _ " --pf-global--danger-color--300: #470000;" & @CRLF & _ " --pf-global--BoxShadow--sm: 0 0.0625rem 0.125rem 0 rgba(3, 3, 3, 0.2);" & @CRLF & _ " --pf-global--BoxShadow--sm-right: 0.25rem 0 0.625rem -0.25rem rgba(3, 3, 3, 0.12);" & @CRLF & _ " --pf-global--BoxShadow--sm-left: -0.25rem 0 0.625rem -0.25rem rgba(3, 3, 3, 0.12);" & @CRLF & _ " --pf-global--BoxShadow--sm-bottom: 0 0.25rem 0.625rem -0.25rem rgba(3, 3, 3, 0.12);" & @CRLF & _ " --pf-global--BoxShadow--sm-top: 0 -0.25rem 0.625rem -0.25rem rgba(3, 3, 3, 0.12);" & @CRLF & _ " --pf-global--BoxShadow--md: 0 0.0625rem 0.0625rem 0rem rgba(3, 3, 3, 0.05), 0 0.25rem 0.5rem 0.25rem rgba(3, 3, 3, 0.06);" & @CRLF & _ " --pf-global--BoxShadow--md-right: 0.3125rem 0 0.625rem -0.25rem rgba(3, 3, 3, 0.25);" & @CRLF & _ " --pf-global--BoxShadow--md-left: -0.3125rem 0 0.625rem -0.25rem rgba(3, 3, 3, 0.25);" & @CRLF & _ " --pf-global--BoxShadow--md-bottom: 0 0.3125rem 0.625rem -0.25rem rgba(3, 3, 3, 0.25);" & @CRLF & _ " --pf-global--BoxShadow--md-top: 0 -0.3125rem 0.625rem -0.25rem rgba(3, 3, 3, 0.25);" & @CRLF & _ " --pf-global--BoxShadow--lg: 0 0.1875rem 0.4375rem 0.1875rem rgba(3, 3, 3, 0.13), 0 0.6875rem 1.5rem 1rem rgba(3, 3, 3, 0.12);" & @CRLF & _ " --pf-global--BoxShadow--lg-right: 0.75rem 0 0.625rem -0.25rem rgba(3, 3, 3, 0.07);" & @CRLF & _ " --pf-global--BoxShadow--lg-left: -0.75rem 0 0.625rem -0.25rem rgba(3, 3, 3, 0.07);" & @CRLF & _ " --pf-global--BoxShadow--lg-bottom: 0 0.75rem 0.625rem -0.25rem rgba(3, 3, 3, 0.07);" & @CRLF & _ " --pf-global--BoxShadow--lg-top: 0 -0.75rem 0.625rem -0.25rem rgba(3, 3, 3, 0.07);" & @CRLF & _ " --pf-global--BoxShadow--inset: inset 0 0 0.625rem 0 rgba(3, 3, 3, 0.25);" & @CRLF & _ " --pf-global--font-path: assets/fonts;" & @CRLF & _ " --pf-global--fonticon-path: assets/pficon;" & @CRLF & _ " --pf-global--spacer--xs: 0.25rem;" & @CRLF & _ " --pf-global--spacer--sm: 0.5rem;" & @CRLF & _ " --pf-global--spacer--md: 1rem;" & @CRLF & _ " --pf-global--spacer--lg: 1.5rem;" & @CRLF & _ " --pf-global--spacer--xl: 2rem;" & @CRLF & _ " --pf-global--spacer--2xl: 3rem;" & @CRLF & _ " --pf-global--spacer--3xl: 4rem;" & @CRLF & _ " --pf-global--spacer--form-element: 0.375rem;" & @CRLF & _ " --pf-global--gutter: 1.5rem;" & @CRLF & _ " --pf-global--gutter--md: 1rem;" & @CRLF & _ " --pf-global--golden-ratio: 1.681;" & @CRLF & _ " --pf-global--ZIndex--xs: 100;" & @CRLF & _ " --pf-global--ZIndex--sm: 200;" & @CRLF & _ " --pf-global--ZIndex--md: 300;" & @CRLF & _ " --pf-global--ZIndex--lg: 400;" & @CRLF & _ " --pf-global--ZIndex--xl: 500;" & @CRLF & _ " --pf-global--ZIndex--2xl: 600;" & @CRLF & _ " --pf-global--breakpoint--xs: 0;" & @CRLF & _ " --pf-global--breakpoint--sm: 576px;" & @CRLF & _ " --pf-global--breakpoint--md: 768px;" & @CRLF & _ " --pf-global--breakpoint--lg: 992px;" & @CRLF & _ " --pf-global--breakpoint--xl: 1200px;" & @CRLF & _ " --pf-global--breakpoint--2xl: 1450px;" & @CRLF & _ " --pf-global--link--Color: #06c;" & @CRLF & _ " --pf-global--link--Color--hover: #004080;" & @CRLF & _ " --pf-global--link--Color--light: #73bcf7;" & @CRLF & _ " --pf-global--link--Color--light--hover: #2b9af3;" & @CRLF & _ " --pf-global--link--Color--dark: #06c;" & @CRLF & _ " --pf-global--link--Color--dark--hover: #004080;" & @CRLF & _ " --pf-global--link--FontWeight: 500;" & @CRLF & _ " --pf-global--link--TextDecoration: none;" & @CRLF & _ " --pf-global--link--TextDecoration--hover: underline;" & @CRLF & _ " --pf-global--BorderWidth--sm: 1px;" & @CRLF & _ " --pf-global--BorderWidth--md: 2px;" & @CRLF & _ " --pf-global--BorderWidth--lg: 3px;" & @CRLF & _ " --pf-global--BorderColor--100: #d2d2d2;" & @CRLF & _ " --pf-global--BorderColor--200: #8a8d90;" & @CRLF & _ " --pf-global--BorderColor--300: #ededed;" & @CRLF & _ " --pf-global--BorderColor--dark-100: #d2d2d2;" & @CRLF & _ " --pf-global--BorderColor--light-100: #b8bbbe;" & @CRLF & _ " --pf-global--BorderRadius--sm: 3px;" & @CRLF & _ " --pf-global--BorderRadius--lg: 30em;" & @CRLF & _ " --pf-global--icon--Color--light: #737679;" & @CRLF & _ " --pf-global--icon--Color--dark: #151515;" & @CRLF & _ " --pf-global--icon--FontSize--sm: 0.625rem;" & @CRLF & _ " --pf-global--icon--FontSize--md: 1.125rem;" & @CRLF & _ " --pf-global--icon--FontSize--lg: 1.5rem;" & @CRLF & _ " --pf-global--icon--FontSize--xl: 3.375rem;" & @CRLF & _ " --pf-global--FontFamily--sans-serif: overpass, overpass, open sans, -apple-system, blinkmacsystemfont, Segoe UI, roboto, Helvetica Neue, arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;" & @CRLF & _ " --pf-global--FontFamily--heading--sans-serif: overpass, overpass, open sans, -apple-system, blinkmacsystemfont, Segoe UI, roboto, Helvetica Neue, arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;" & @CRLF & _ " --pf-global--FontFamily--monospace: overpass-mono, overpass-mono, SFMono-Regular, menlo, monaco, consolas, Liberation Mono, Courier New, monospace;" & @CRLF & _ " --pf-global--FontFamily--redhatfont--sans-serif: RedHatText, Overpass, overpass, helvetica, arial, sans-serif;" & @CRLF & _ " --pf-global--FontFamily--redhatfont--heading--sans-serif: RedHatDisplay, Overpass, overpass, helvetica, arial, sans-serif;" & @CRLF & _ " --pf-global--FontFamily--redhatfont--monospace: Liberation Mono, consolas, SFMono-Regular, menlo, monaco, Courier New, monospace;" & @CRLF & _ " --pf-global--FontSize--4xl: 2.25rem;" & @CRLF & _ " --pf-global--FontSize--3xl: 1.75rem;" & @CRLF & _ " --pf-global--FontSize--2xl: 1.5rem;" & @CRLF & _ " --pf-global--FontSize--xl: 1.25rem;" & @CRLF & _ " --pf-global--FontSize--lg: 1.125rem;" & @CRLF & _ " --pf-global--FontSize--md: 1rem;" & @CRLF & _ " --pf-global--FontSize--sm: 0.875rem;" & @CRLF & _ " --pf-global--FontSize--xs: 0.75rem;" & @CRLF & _ " --pf-global--FontWeight--light: 300;" & @CRLF & _ " --pf-global--FontWeight--normal: 400;" & @CRLF & _ " --pf-global--FontWeight--semi-bold: 500;" & @CRLF & _ " --pf-global--FontWeight--bold: 600;" & @CRLF & _ " --pf-global--FontWeight--redhatfont--bold: 700;" & @CRLF & _ " --pf-global--LineHeight--sm: 1.3;" & @CRLF & _ " --pf-global--LineHeight--md: 1.5;" & @CRLF & _ " --pf-global--ListStyle: disc outside;" & @CRLF & _ " --pf-global--Transition: all 250ms cubic-bezier(0.42, 0, 0.58, 1);" & @CRLF & _ " --pf-global--TimingFunction: cubic-bezier(0.645, 0.045, 0.355, 1);" & @CRLF & _ " --pf-global--TransitionDuration: 250ms;" & @CRLF & _ " --pf-global--arrow--width: 0.9375rem;" & @CRLF & _ " --pf-global--arrow--width-lg: 1.5625rem;" & @CRLF & _ " --pf-global--target-size--MinWidth: 44px;" & @CRLF & _ " --pf-global--target-size--MinHeight: 44px; }" & @CRLF & _ "" & @CRLF & _ ".pf-m-redhat-font {" & @CRLF & _ " --pf-global--FontFamily--sans-serif: var(--pf-global--FontFamily--redhatfont--sans-serif);" & @CRLF & _ " --pf-global--FontFamily--heading--sans-serif: var(--pf-global--FontFamily--redhatfont--heading--sans-serif);" & @CRLF & _ " --pf-global--FontFamily--monospace: var(--pf-global--FontFamily--redhatfont--monospace);" & @CRLF & _ " --pf-global--FontWeight--semi-bold: var(--pf-global--FontWeight--redhatfont--bold);" & @CRLF & _ " --pf-global--FontWeight--bold: var(--pf-global--FontWeight--redhatfont--bold);" & @CRLF & _ " --pf-global--link--FontWeight: var(--pf-global--FontWeight--normal); }" & @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