Regular Expressions 101

Save & Share

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)\d\d.-?.\w.-?.\d\d" Local $sString = "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen-533 Berkshire 5 min 27-Jun-18 14:27 9.0 --- --- 0.08" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen-533 Berkshire 27-Jun-18 9.0 18.9 7.7 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen 247 Brock Street North 27-Jun-18 13.0 19 7.6 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen 245 Brock St N 5min 09-Jul-18 14:35 9.0 --- --- 12.1" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen 245 Brock St N 09-Jul-18 9.0 7.5 22.4 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen-665 Cherry Dr 5min 21-Jun-18 11:04 8.0 --- 3.93" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen-665 Cherry Dr 21-Jun-18 8.0 7.7 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen 1390 Christina Street North 10-Oct-18 16.0 7.6 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen 140 Conrad St 09-Jul-18 9.0 7.6 21.6 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen 763 Copland 27-Jun-18 13.0 19.3 7.6 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen-560 Cromwell St 5th 09-May-18 13:37 12.0 --- 16.1" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen-560 Cromwell St 09-May-18 12.0 7.0 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen 534 Davis Street 5min 30-Aug-18 14:34 17.0 --- 9.05" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen 534 Davis Street 30-Aug-18 --- 7.5 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen-534 Devine St 5min 25-Jun-18 08:04 10.0 --- --- 0.05" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen-534 Devine St 25-Jun-18 10.0 6.6 18.4 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen 845 Devine St-5 Min 26-Jun-18 12:43 8.0 --- --- 75 0.17" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen 845 Devine St 26-Jun-18 8.0 18.5 7.6 --- ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen 357 East St-5 26-Sep-18 09:04 19.0 --- 0.09" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen 357 East St 19.0 7.8 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen 357 East St-1 26-Sep-18 09:34 19.0 --- 0.27" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen 357 East St-2 26-Sep-18 09:34 19.0 --- 0.14" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:55 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen 306 Elgin St 10-Oct-18 16.0 8.0 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen 308 Elgin St-1 26-Sep-18 11:32 19.0 --- 6.47" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-641 Elm Ave 09-May-18 12.0 6.7 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-267 Emma St 29-May-18 11.0 7.8 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-272 Emma St 24-May-18 11.0 7.3 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-278 Emma St 29-May-18 11.0 7.4 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-297 Emma St 24-May-18 11.0 7.3 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-301 Emma 24-May-18 11.0 7.2 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-248 Emma St 08-May-18 16.0 7.4 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-257 Emma St 5th 08-May-18 12:30 16.0 --- 1.21" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-263 Emma St 07-May-18 16.0 7.8 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-273 Emma St 07-May-18 12:41 16.0 7.7 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-277 Emma St 08-May-18 16.0 7.8 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-281 Emma St 07-May-18 13:48 16.0 7.9 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-284 Emma St 08-May-18 16.0 7.8 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-291 Emma St 07-May-18 14:30 16.0 7.8 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-299 Emma St 08-May-18 16.0 7.6 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-300 Emma St 08-May-18 16.0 7.9 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-247 Emma St 09-May-18 12.0 7.9 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-288 Emma St 10-May-18 12.0 7.8 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-303 Emma St 10-May-18 12.0 7.6 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:57 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:57 : NR Kitchen 320 Exmouth 12-Jul-18 8.0 21.9 7.6 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:57 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:57 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:57 : NR Kitchen 571 Flamingo DR 5 03-Oct-18 09:16 Curtis Salisbury 16.0 --- 0.07" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:57 : NR Kitchen 571 Flamingo DR 03-Oct-18 Curtis Salisbury 16.0 7.9 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:57 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:57 : NR Kitchen 590 Flamingo 5min 14-Aug-18 15:04 12.0 --- --- 0.08" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:57 : NR Kitchen 590 Flamingo 14-Aug-18 12.0 7.6 22.3 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:57 : -NR" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:57 : NR Kitchen 122 Forsyth North 31-Jul-18 Curtis Salisbury 12.0 21.6 7.4 ---" & @CRLF & _ "root - ERROR - : 06/05/2019, 14:29:57 : -NR" & @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