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))(?:(?<!\s\s)\:\s+)((?:[\-\+])?\d+\.\d+|\w+$|[\-\+]\d+|\w+\s\d+)" Local $sString = "Beam Number : 2" & @CRLF & _ "Beam Name : CCW" & @CRLF & _ "Original MU : 1995.39040729" & @CRLF & _ "" & @CRLF & _ "Logging Scale : IEC 1217" & @CRLF & _ "X1 (Cms): -2.50" & @CRLF & _ "X2 (Cms): +2.20" & @CRLF & _ "Y1 (Cms): -2.60" & @CRLF & _ "Y2 (Cms): +2.50" & @CRLF & _ "Gantry Rotation Angle (deg): 87.73" & @CRLF & _ "Energy : 6x" & @CRLF & _ "MU1 : 1007.63" & @CRLF & _ "MU2 : 1009.05" & @CRLF & _ "Radiation Time (mins): 1.6807" & @CRLF & _ "DoseRate (MU/min): 598.32" & @CRLF & _ "PFN High Voltage Power Supply Current (A): 1.908875" & @CRLF & _ "PFN Actual Voltage (KV): 18.21791" & @CRLF & _ "RF Driver Voltage (V): 4.365" & @CRLF & _ "RF Forward Power (W): 1.516418" & @CRLF & _ "AFC Error (V): -0.000601778" & @CRLF & _ "Gun Current (A): 0.3430939" & @CRLF & _ "Gun High Voltage (V): -14965" & @CRLF & _ "Gun Grid Voltage (V): 97.55565" & @CRLF & _ "Gun Filament Step Voltage (V): 5.300003" & @CRLF & _ "Gun Filament Voltage (V): 5.405273" & @CRLF & _ "Bend Magnet Current (A): 16.18042" & @CRLF & _ "Bend Magnet Voltage (V): 2.283325" & @CRLF & _ "Accelerator Solenoid Current (A): 34.95636" & @CRLF & _ "Klystron Solenoid Current (A): 34.95789" & @CRLF & _ "Radial Symmetry (%): 0.00045321" & @CRLF & _ "Transverse Symmetry (%): 0.00044355" & @CRLF & _ "Target Current (nC): 315.4927" & @CRLF & _ "Buncher Radial Current (A): 0.005020142" & @CRLF & _ "Buncher Transverse Current (A): -0.06005859" & @CRLF & _ "Angle Radial Current (A): 0.005279541" & @CRLF & _ "Angle Transverse Current (A): 0.06143188" & @CRLF & _ "Position Radial Current (A): -0.8885803" & @CRLF & _ "Position Transverse Current (A): -0.5808258" & @CRLF & _ "Trim : (A) -0.06399536" & @CRLF & _ "Accelerator Vacion Current (uA): 0.009002686" & @CRLF & _ "Positive 5V dc: 4.993916" & @CRLF & _ "Positive 24V dc: 24.4706" & @CRLF & _ "Analog Negative 5V dc: 5.054981" & @CRLF & _ "Analog Positive 5V dc: 4.97241" & @CRLF & _ "Negative 12V dc: 12.24357" & @CRLF & _ "Positive 3V dc: 3.303525" & @CRLF & _ "Node Power Supply Voltage (V): 24.58121" & @CRLF & _ "Water Level : Normal" & @CRLF & _ "City Water Temperature (deg C): 20.54332" & @CRLF & _ "Internal Water Supply Temperature (deg C): 40.51909" & @CRLF & _ "Gas Pressure (PSI): 32.3421" 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