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
No Match

/
/
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 = "\b([KNW][A-Z]?|A[A-L])[0-9][A-Z]{1,3}\b(?:-@)?" Local $sString = "$pattern .= ""; //N9URK, W1AW, W1W" & @CRLF & _ "$pattern .= ""; //WB6NOA, AD4HZ, WA1W" & @CRLF & _ "IW1GJR" & @CRLF & _ "K, N, W, AA-AL, KA-KZ, NA-NZ or WA-WZ" & @CRLF & _ "" & @CRLF & _ "All of these returning false with RegEx.test in JavaScript:" & @CRLF & _ "pen.js:23 JA1HOX" & @CRLF & _ "pen.js:23 IQ6WJ" & @CRLF & _ "pen.js:23 CE2AWW" & @CRLF & _ "pen.js:23 SK2AT" & @CRLF & _ "pen.js:23 IW1EVR" & @CRLF & _ "pen.js:23 9A3LE-@" & @CRLF & _ "pen.js:23 EA5IGO" & @CRLF & _ "pen.js:23 SK2AT" & @CRLF & _ "pen.js:23 W6BOI <-------" & @CRLF & _ "pen.js:23 IZ3ZUS" & @CRLF & _ "pen.js:23 YO3YX" & @CRLF & _ "pen.js:23 ON4LDP" & @CRLF & _ "pen.js:23 BG3UPA" & @CRLF & _ "pen.js:23 FW5JJ" & @CRLF & _ "pen.js:23 RM4D-@" & @CRLF & _ "pen.js:23 RN3QTS" & @CRLF & _ "pen.js:23 OH6PA" & @CRLF & _ "pen.js:23 W3LPL <-------" & @CRLF & _ "pen.js:23 SK2AT" & @CRLF & _ "pen.js:23 K2CYS" & @CRLF & _ "pen.js:23 EW4DW" & @CRLF & _ "pen.js:23 EC1DJ" & @CRLF & _ "pen.js:23 R3NA" & @CRLF & _ "pen.js:23 JA6GGD" & @CRLF & _ "pen.js:23 N3YZ-@" & @CRLF & _ "pen.js:23 K0BX" & @CRLF & _ "pen.js:23 WA2VUY-@" & @CRLF & _ "pen.js:23 IZ3WXG" & @CRLF & _ "pen.js:23 DD3EU-@" & @CRLF & _ "pen.js:23 UR4UWY-@" & @CRLF & _ "pen.js:23 ON4LDP" & @CRLF & _ "pen.js:23 K5VJZ" & @CRLF & _ "pen.js:23 RZ3LA-@" & @CRLF & _ "pen.js:23 OE9NFI" & @CRLF & _ "pen.js:23 OH1F" & @CRLF & _ "pen.js:23 K2CYS" & @CRLF & _ "pen.js:23 HA0DU" & @CRLF & _ "pen.js:23 EB8CRM" & @CRLF & _ "pen.js:23 TA2OTT-@" & @CRLF & _ "pen.js:23 EA1AST" & @CRLF & _ "pen.js:23 N0TR" & @CRLF & _ "pen.js:23 RK6FV" & @CRLF & _ "pen.js:23 YU7AF" & @CRLF & _ "pen.js:23 F0FVK" & @CRLF & _ "pen.js:23 FW5JJ" & @CRLF & _ "pen.js:23 R2ZA-@" & @CRLF & _ "pen.js:23 G0LGS" & @CRLF & _ "pen.js:23 5B4AIZ-@" & @CRLF & _ "pen.js:23 RZ3LA-@" & @CRLF & _ "" & @CRLF & _ "7275 N4N 2015-10-06T19:32:38 military convoy SE United States N8POG" & @CRLF & _ "7183 LZ130SAK 2015-10-06T19:30:04 CQ cq SES AWARD Bulgaria DL2AMM" & @CRLF & _ "7275 N4N 2015-10-06T19:29:03 Bankhead Convoy Host Station United States KA4WJR-@" & @CRLF & _ "18163 CN8NOA 2015-10-06T19:28:22 your dear friend NORI Morocco W4QNW" & @CRLF & _ "14268 S79SP 2015-10-06T19:28:16 Listening up Seychelles WA3ZHG-@" & @CRLF & _ "1846 HG8ITU 2015-10-06T19:27:18 CQ RTTY RTTY Hungary HA8BT" & @CRLF & _ "14260 W1AW 2015-10-06T19:26:06 tnx United States IW1GJR" & @CRLF & _ "14268 S79SP 2015-10-06T19:25:53 59 EPA by mumbers up10 Seychelles W3RJW" 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