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

/
/
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 = "(?:['\"`]([^'\"`]*)['\"`])" Local $sString = "export default {" & @CRLF & _ " root: ({ props, context, parent }) => ({" & @CRLF & _ " class: [" & @CRLF & _ " 'relative'," & @CRLF & _ "" & @CRLF & _ " // Alignments" & @CRLF & _ " 'items-center inline-flex text-center align-bottom justify-center'," & @CRLF & _ "" & @CRLF & _ " // Sizes & Spacing" & @CRLF & _ " 'leading-[normal]'," & @CRLF & _ " {" & @CRLF & _ " 'px-4 py-3': props.size === null," & @CRLF & _ " 'text-sm py-2 px-3': props.size === 'small'," & @CRLF & _ " 'text-xl py-3 px-4': props.size === 'large'" & @CRLF & _ " }," & @CRLF & _ " {" & @CRLF & _ " 'w-12 p-0 py-3': props.label == null && props.icon !== null" & @CRLF & _ " }," & @CRLF & _ "" & @CRLF & _ " // Shapes" & @CRLF & _ " { 'shadow-lg': props.raised }," & @CRLF & _ " { 'rounded-md': !props.rounded, 'rounded-full': props.rounded }," & @CRLF & _ " { 'rounded-none first:rounded-l-md last:rounded-r-md': parent.instance.$name == 'InputGroup' }," & @CRLF & _ "" & @CRLF & _ " // Link Button" & @CRLF & _ " { 'text-primary-600 bg-transparent border-transparent': props.link }," & @CRLF & _ "" & @CRLF & _ " // Plain Button" & @CRLF & _ " { 'text-white bg-gray-500 border border-gray-500': props.plain && !props.outlined && !props.text }," & @CRLF & _ " // Plain Text Button" & @CRLF & _ " { 'text-surface-500': props.plain && props.text }," & @CRLF & _ " // Plain Outlined Button" & @CRLF & _ " { 'text-surface-500 border border-gray-500': props.plain && props.outlined }," & @CRLF & _ "" & @CRLF & _ " // Text Button" & @CRLF & _ " { 'bg-transparent border-transparent': props.text && !props.plain }," & @CRLF & _ "" & @CRLF & _ " // Outlined Button" & @CRLF & _ " { 'bg-transparent border': props.outlined && !props.plain }," & @CRLF & _ "" & @CRLF & _ " // --- Severity Buttons ---" & @CRLF & _ "" & @CRLF & _ " // Primary Button" & @CRLF & _ " {" & @CRLF & _ " 'text-primary-inverse': !props.link && props.severity === null && !props.text && !props.outlined && !props.plain," & @CRLF & _ " 'bg-primary': !props.link && props.severity === null && !props.text && !props.outlined && !props.plain," & @CRLF & _ " 'border border-primary': !props.link && props.severity === null && !props.text && !props.outlined && !props.plain" & @CRLF & _ " }," & @CRLF & _ " // Primary Text Button" & @CRLF & _ " { 'text-primary': props.text && props.severity === null && !props.plain }," & @CRLF & _ " // Primary Outlined Button" & @CRLF & _ " { 'text-primary border border-primary': props.outlined && props.severity === null && !props.plain }," & @CRLF & _ "" & @CRLF & _ " // Secondary Button" & @CRLF & _ " {" & @CRLF & _ " 'text-white dark:text-surface-900': props.severity === 'secondary' && !props.text && !props.outlined && !props.plain," & @CRLF & _ " 'bg-surface-500 dark:bg-surface-400': props.severity === 'secondary' && !props.text && !props.outlined && !props.plain," & @CRLF & _ " 'border border-surface-500 dark:border-surface-400': props.severity === 'secondary' && !props.text && !props.outlined && !props.plain" & @CRLF & _ " }," & @CRLF & _ " // Secondary Text Button" & @CRLF & _ " { 'text-surface-500 dark:text-surface-300': props.text && props.severity === 'secondary' && !props.plain }," & @CRLF & _ " // Secondary Outlined Button" & @CRLF & _ " { 'text-surface-500 dark:text-surface-300 border border-surface-500 hover:bg-surface-300/20': props.outlined && props.severity === 'secondary' && !props.plain }," & @CRLF & _ "" & @CRLF & _ " // Success Button" & @CRLF & _ " {" & @CRLF & _ " 'text-white dark:text-green-900': props.severity === 'success' && !props.text && !props.outlined && !props.plain," & @CRLF & _ " 'bg-green-500 dark:bg-green-400': props.severity === 'success' && !props.text && !props.outlined && !props.plain," & @CRLF & _ " 'border border-green-500 dark:border-green-400': props.severity === 'success' && !props.text && !props.outlined && !props.plain" & @CRLF & _ " }," & @CRLF & _ " // Success Text Button" & @CRLF & _ " { 'text-green-500 dark:text-green-400': props.text && props.severity === 'success' && !props.plain }," & @CRLF & _ " // Success Outlined Button" & @CRLF & _ " { 'text-green-500 border border-green-500 hover:bg-green-300/20': props.outlined && props.severity === 'success' && !props.plain }," & @CRLF & _ "" & @CRLF & _ " // Info Button" & @CRLF & _ " {" & @CRLF & _ " 'text-white dark:text-surface-900': props.severity === 'info' && !props.text && !props.outlined && !props.plain," & @CRLF & _ " 'bg-blue-500 dark:bg-blue-400': props.severity === 'info' && !props.text && !props.outlined && !props.plain," & @CRLF & _ " 'border border-blue-500 dark:border-blue-400': props.severity === 'info' && !props.text && !props.outlined && !props.plain" & @CRLF & _ " }," & @CRLF & _ " // Info Text Button" & @CRLF & _ " { 'text-blue-500 dark:text-blue-400': props.text && props.severity === 'info' && !props.plain }," & @CRLF & _ " // Info Outlined Button" & @CRLF & _ " { 'text-blue-500 border border-blue-500 hover:bg-blue-300/20 ': props.outlined && props.severity === 'info' && !props.plain }," & @CRLF & _ "" & @CRLF & _ " // Warning Button" & @CRLF & _ " {" & @CRLF & _ " 'text-white dark:text-surface-900': props.severity === 'warning' && !props.text && !props.outlined && !props.plain," & @CRLF & _ " 'bg-orange-500 dark:bg-orange-400': props.severity === 'warning' && !props.text && !props.outlined && !props.plain," & @CRLF & _ " 'border border-orange-500 dark:border-orange-400': props.severity === 'warning' && !props.text && !props.outlined && !props.plain" & @CRLF & _ " }," & @CRLF & _ " // Warning Text Button" & @CRLF & _ " { 'text-orange-500 dark:text-orange-400': props.text && props.severity === 'warning' && !props.plain }," & @CRLF & _ " // Warning Outlined Button" & @CRLF & _ " { 'text-orange-500 border border-orange-500 hover:bg-orange-300/20': props.outlined && props.severity === 'warning' && !props.plain }," & @CRLF & _ "" & @CRLF & _ " // Help Button" & @CRLF & _ " {" & @CRLF & _ " 'text-white dark:text-surface-900': props.severity === 'help' && !props.text && !props.outlined && !props.plain," & @CRLF & _ " 'bg-purple-500 dark:bg-purple-400': props.severity === 'help' && !props.text && !props.outlined && !props.plain," & @CRLF & _ " 'border border-purple-500 dark:border-purple-400': props.severity === 'help' && !props.text && !props.outlined && !props.plain" & @CRLF & _ " }," & @CRLF & _ " // Help Text Button" & @CRLF & _ " { 'text-purple-500 dark:text-purple-400': props.text && props.severity === 'help' && !props.plain }," & @CRLF & _ " // Help Outlined Button" & @CRLF & _ " { 'text-purple-500 border border-purple-500 hover:bg-purple-300/20': props.outlined && props.severity === 'help' && !props.plain }," & @CRLF & _ "" & @CRLF & _ " // Danger Button" & @CRLF & _ " {" & @CRLF & _ " 'text-white dark:text-surface-900': props.severity === 'danger' && !props.text && !props.outlined && !props.plain," & @CRLF & _ " 'bg-red-500 dark:bg-red-400': props.severity === 'danger' && !props.text && !props.outlined && !props.plain," & @CRLF & _ " 'border border-red-500 dark:border-red-400': props.severity === 'danger' && !props.text && !props.outlined && !props.plain" & @CRLF & _ " }," & @CRLF & _ " // Danger Text Button" & @CRLF & _ " { 'text-red-500 dark:text-red-400': props.text && props.severity === 'danger' && !props.plain }," & @CRLF & _ " // Danger Outlined Button" & @CRLF & _ " { 'text-red-500 border border-red-500 hover:bg-red-300/20': props.outlined && props.severity === 'danger' && !props.plain }," & @CRLF & _ " // Contrast Button" & @CRLF & _ " {" & @CRLF & _ " 'text-white dark:text-surface-900': props.severity === 'contrast' && !props.text && !props.outlined && !props.plain," & @CRLF & _ " 'bg-surface-900 dark:bg-surface-0': props.severity === 'contrast' && !props.text && !props.outlined && !props.plain," & @CRLF & _ " 'border border-surface-900 dark:border-surface-0': props.severity === 'contrast' && !props.text && !props.outlined && !props.plain" & @CRLF & _ " }," & @CRLF & _ " // Contrast Text Button" & @CRLF & _ " { 'text-surface-900 dark:text-surface-0': props.text && props.severity === 'contrast' && !props.plain }," & @CRLF & _ " // Contrast Outlined Button" & @CRLF & _ " { 'text-surface-900 dark:text-surface-0 border border-surface-900 dark:border-surface-0': props.outlined && props.severity === 'contrast' && !props.plain }," & @CRLF & _ "" & @CRLF & _ " // --- Severity Button States ---" & @CRLF & _ " 'focus:outline-none focus:outline-offset-0 focus:ring'," & @CRLF & _ "" & @CRLF & _ " // Link" & @CRLF & _ " { 'focus:ring-primary': props.link }," & @CRLF & _ "" & @CRLF & _ " // Plain" & @CRLF & _ " { 'hover:bg-gray-600 hover:border-gray-600': props.plain && !props.outlined && !props.text }," & @CRLF & _ " // Text & Outlined Button" & @CRLF & _ " { 'hover:bg-surface-300/20': props.plain && (props.text || props.outlined) }," & @CRLF & _ "" & @CRLF & _ " // Primary" & @CRLF & _ " { 'hover:bg-primary-hover hover:border-primary-hover': !props.link && props.severity === null && !props.text && !props.outlined && !props.plain }," & @CRLF & _ " { 'focus:ring-primary': props.severity === null }," & @CRLF & _ " // Text & Outlined Button" & @CRLF & _ " { 'hover:bg-primary-300/20': (props.text || props.outlined) && props.severity === null && !props.plain }," & @CRLF & _ "" & @CRLF & _ " // Secondary" & @CRLF & _ " { 'hover:bg-surface-600 dark:hover:bg-surface-300 hover:border-surface-600 dark:hover:border-surface-300': props.severity === 'secondary' && !props.text && !props.outlined && !props.plain }," & @CRLF & _ " { 'focus:ring-surface-400/50 dark:focus:ring-surface-300/50': props.severity === 'secondary' }," & @CRLF & _ " // Text & Outlined Button" & @CRLF & _ " { 'hover:bg-surface-300/20': (props.text || props.outlined) && props.severity === 'secondary' && !props.plain }," & @CRLF & _ "" & @CRLF & _ " // Success" & @CRLF & _ " { 'hover:bg-green-600 dark:hover:bg-green-300 hover:border-green-600 dark:hover:border-green-300': props.severity === 'success' && !props.text && !props.outlined && !props.plain }," & @CRLF & _ " { 'focus:ring-green-400/50 dark:focus:ring-green-300/50': props.severity === 'success' }," & @CRLF & _ " // Text & Outlined Button" & @CRLF & _ " { 'hover:bg-green-300/20': (props.text || props.outlined) && props.severity === 'success' && !props.plain }," & @CRLF & _ "" & @CRLF & _ " // Info" & @CRLF & _ " { 'hover:bg-blue-600 dark:hover:bg-blue-300 hover:border-blue-600 dark:hover:border-blue-300': props.severity === 'info' && !props.text && !props.outlined && !props.plain }," & @CRLF & _ " { 'focus:ring-blue-400/50 dark:focus:ring-blue-300/50': props.severity === 'info' }," & @CRLF & _ " // Text & Outlined Button" & @CRLF & _ " { 'hover:bg-blue-300/20': (props.text || props.outlined) && props.severity === 'info' && !props.plain }," & @CRLF & _ "" & @CRLF & _ " // Warning" & @CRLF & _ " { 'focus:ring-orange-400/50 dark:focus:ring-orange-300/50': props.severity === 'warning' }," & @CRLF & _ " // Text & Outlined Button" & @CRLF & _ " { 'hover:bg-orange-600 ': props.severity === 'warning' }," & @CRLF & _ " // Text & Outlined Button" & @CRLF & _ " { 'hover:bg-orange-600 ': props.severity === 'warning' }," & @CRLF & _ " // Text & Outlined Button" & @CRLF & _ " { 'hover:bg-orange-300/20': (props.text || props.outlined) && props.severity === 'warning' && !props.plain }," & @CRLF & _ "" & @CRLF & _ " // Help" & @CRLF & _ " { 'hover:bg-purple-600 dark:hover:bg-purple-300 hover:border-purple-600 dark:hover:border-purple-300': props.severity === 'help' && !props.text && !props.outlined && !props.plain }," & @CRLF & _ " { 'focus:ring-purple-400/50 dark:focus:ring-purple-300/50': props.severity === 'help' }," & @CRLF & _ " // Text & Outlined Button" & @CRLF & _ " { 'hover:bg-purple-300/20': (props.text || props.outlined) && props.severity === 'help' && !props.plain }," & @CRLF & _ "" & @CRLF & _ " // Danger" & @CRLF & _ " { 'hover:bg-red-600 dark:hover:bg-red-300 hover:border-red-600 dark:hover:border-red-300': props.severity === 'danger' && !props.text && !props.outlined && !props.plain }," & @CRLF & _ " { 'focus:ring-red-400/50 dark:focus:ring-red-300/50': props.severity === 'danger' }," & @CRLF & _ " // Text & Outlined Button" & @CRLF & _ " { 'hover:bg-red-300/20': (props.text || props.outlined) && props.severity === 'danger' && !props.plain }," & @CRLF & _ " // Contrast" & @CRLF & _ " { 'hover:bg-surface-800 dark:hover:bg-surface-100 hover:border-surface-800 dark:hover:border-surface-100': props.severity === 'contrast' && !props.text && !props.outlined && !props.plain }," & @CRLF & _ " { 'focus:ring-surface-500 dark:focus:ring-surface-400': props.severity === 'contrast' }," & @CRLF & _ " // Text & Outlined Button" & @CRLF & _ " { 'hover:bg-surface-900/10 dark:hover:bg-[rgba(255,255,255,0.03)]': (props.text || props.outlined) && props.severity === 'contrast' && !props.plain }," & @CRLF & _ " // Disabled" & @CRLF & _ " { 'opacity-60 pointer-events-none cursor-default': context.disabled }," & @CRLF & _ "" & @CRLF & _ " // Transitions" & @CRLF & _ " 'transition duration-200 ease-in-out'," & @CRLF & _ "" & @CRLF & _ " // Misc" & @CRLF & _ " 'cursor-pointer overflow-hidden select-none'" & @CRLF & _ " ]" & @CRLF & _ " })," & @CRLF & _ " label: ({ props }) => ({" & @CRLF & _ " class: [" & @CRLF & _ " 'duration-200 p-4 mt-4 mb-9 ring-1 '," & @CRLF & _ " 'font-bold'," & @CRLF & _ " {" & @CRLF & _ " 'hover:underline': props.link" & @CRLF & _ " }," & @CRLF & _ " { 'flex-1': props.label !== null, 'invisible w-0': props.label == null }" & @CRLF & _ " ]" & @CRLF & _ " })," & @CRLF & _ " icon: ({ props }) => ({" & @CRLF & _ " class: [" & @CRLF & _ " 'mx-0'," & @CRLF & _ " {" & @CRLF & _ " 'mr-2': props.iconPos == 'left' && props.label != null," & @CRLF & _ " 'ml-2 order-1': props.iconPos == 'right' && props.label != null," & @CRLF & _ " 'mb-2': props.iconPos == 'top' && props.label != null," & @CRLF & _ " 'mt-2': props.iconPos == 'bottom' && props.label != null" & @CRLF & _ " }" & @CRLF & _ " ]" & @CRLF & _ " })," & @CRLF & _ " loadingicon: ({ props }) => ({" & @CRLF & _ " class: [" & @CRLF & _ " 'h-4 w-4'," & @CRLF & _ " 'mx-0'," & @CRLF & _ " {" & @CRLF & _ " 'ml-2 order-1': props.iconPos == 'right' && props.label != null," & @CRLF & _ " 'mb-2': props.iconPos == 'top' && props.label != null," & @CRLF & _ " 'mt-2': props.iconPos == 'bottom' && props.label != null" & @CRLF & _ " }," & @CRLF & _ " 'animate-spin'" & @CRLF & _ " ]" & @CRLF & _ " })," & @CRLF & _ " badge: ({ props }) => ({" & @CRLF & _ " class: [ { 'ml-2 w-4 h-4 leading-none flex items-center justify-center': props.badge } ]" & @CRLF & _ " })" & @CRLF & _ "}" & @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