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

Substitution
Processing...

Code Generator

Generated Code

#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox Local $sRegex = "(?m)(\d*\.\d*)( lb \(\d*\.*\d* kg\))" Local $sString = "Age Weight Length" & @CRLF & _ "0 7.4 lb (3.3 kg) 19.6" (49.8 cm)" & @CRLF & _ "1 21.3 lb (9.6 kg) 29.8" (75.7 cm)" & @CRLF & _ "2 27.5 lb (12.5 kg) 34.2" (86.8 cm)" & @CRLF & _ "3 31.0 lb (14.0 kg) 37.5" (95.2 cm)" & @CRLF & _ "4 36.0 lb (16.3 kg) 40.3" (102.3 cm)" & @CRLF & _ "5 40.5 lb (18.4 kg) 43.0" (109.2 cm)" & @CRLF & _ "6 45.5 lb (20.6 kg) 45.5" (115.5 cm)" & @CRLF & _ "7 50.5 lb (22.9 kg) 48.0" (121.9 cm)" & @CRLF & _ "8 56.5 lb (25.6 kg) 50.4" (128 cm)" & @CRLF & _ "9 63.0 lb (28.6 kg) 52.5" (133.3 cm)" & @CRLF & _ "10 70.5 lb (32 kg) 54.5" (138.4 cm)" & @CRLF & _ "11 78.5 lb (35.6 kg) 56.5" (143.5 cm)" & @CRLF & _ "12 88.0 lb (39.9 kg) 58.7" (149.1 cm)" & @CRLF & _ "13 100.0 lb (45.3 kg) 61.5" (156.2 cm)" & @CRLF & _ "14 112.0 lb (50.8 kg) 64.5" (163.8 cm)" & @CRLF & _ "15 123.5 lb (56.0 kg) 67.0" (170.1 cm)" & @CRLF & _ "16 134.0 lb (60.8 kg) 68.3" (173.4 cm)" & @CRLF & _ "17 142.0 lb (64.4 kg) 69.0" (175.2 cm)" & @CRLF & _ "18 147.5 lb (66.9 kg) 69.2" (175.7 cm)" & @CRLF & _ "19 152.0 lb (68.9 kg) 69.5" (176.5 cm)" & @CRLF & _ "20 155.0 lb (70.3 kg) 69.7" (177 cm)" & @CRLF & _ "" Local $sSubst = "\1" Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst) MsgBox($MB_SYSTEMMODAL, "Result", $sResult)

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