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+\d+\.\d+:\s+\[(?<matching_string>\w+\s+\w+)" Local $sString = "2019-01-17T15:59:28.172+0100: 3093.554: [GC pause (G1 Evacuation Pause) (young), 0.1252055 secs]" & @CRLF & _ " [Parallel Time: 69.7 ms, GC Workers: 11]" & @CRLF & _ " [GC Worker Start (ms): Min: 3093555.2, Avg: 3093558.8, Max: 3093566.0, Diff: 10.8]" & @CRLF & _ " [Ext Root Scanning (ms): Min: 0.0, Avg: 1.6, Max: 8.4, Diff: 8.4, Sum: 17.4]" & @CRLF & _ " [Update RS (ms): Min: 0.0, Avg: 1.1, Max: 2.3, Diff: 2.3, Sum: 12.0]" & @CRLF & _ " [Processed Buffers: Min: 0, Avg: 7.5, Max: 33, Diff: 33, Sum: 83]" & @CRLF & _ " [Scan RS (ms): Min: 0.2, Avg: 1.7, Max: 2.8, Diff: 2.6, Sum: 18.9]" & @CRLF & _ " [Code Root Scanning (ms): Min: 0.0, Avg: 0.9, Max: 9.0, Diff: 9.0, Sum: 9.8]" & @CRLF & _ " [Object Copy (ms): Min: 53.7, Avg: 60.6, Max: 63.1, Diff: 9.4, Sum: 666.4]" & @CRLF & _ " [Termination (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]" & @CRLF & _ " [Termination Attempts: Min: 1, Avg: 1.0, Max: 1, Diff: 0, Sum: 11]" & @CRLF & _ " [GC Worker Other (ms): Min: 0.0, Avg: 0.1, Max: 0.1, Diff: 0.1, Sum: 0.9]" & @CRLF & _ " [GC Worker Total (ms): Min: 58.8, Avg: 65.9, Max: 69.6, Diff: 10.8, Sum: 725.4]" & @CRLF & _ " [GC Worker End (ms): Min: 3093624.7, Avg: 3093624.7, Max: 3093624.8, Diff: 0.1]" & @CRLF & _ " [Code Root Fixup: 0.2 ms]" & @CRLF & _ " [Code Root Purge: 0.1 ms]" & @CRLF & _ " [Clear CT: 1.3 ms]" & @CRLF & _ " [Other: 54.0 ms]" & @CRLF & _ " [Choose CSet: 0.0 ms]" & @CRLF & _ " [Ref Proc: 44.6 ms]" & @CRLF & _ " [Ref Enq: 1.0 ms]" & @CRLF & _ " [Redirty Cards: 0.4 ms]" & @CRLF & _ " [Humongous Register: 1.1 ms]" & @CRLF & _ " [Humongous Reclaim: 0.0 ms]" & @CRLF & _ " [Free CSet: 6.1 ms]" & @CRLF & _ " [Eden: 16.5G(16.5G)->0.0B(16.4G) Survivors: 272.0M->456.0M Heap: 18.2G(28.0G)->1871.9M(28.0G)]" & @CRLF & _ " [Times: user=1.22 sys=0.03, real=0.12 secs] " & @CRLF & _ " 2019-01-17T16:00:39.144+0100: 3164.525: [Full GC (Heap Inspection Initiated GC) 5595M->1101M(28G), 4.2044268 secs]" & @CRLF & _ " [Eden: 3720.0M(16.4G)->0.0B(16.8G) Survivors: 456.0M->0.0B Heap: 5595.9M(28.0G)->1101.3M(28.0G)], [Metaspace: 187278K->187274K(1216512K)]" & @CRLF & _ " [Times: user=5.76 sys=0.06, real=4.20 secs] " 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