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

`
`
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)^([a-zA-Z0-9-]{1,})>(.*?)[,](.*){1,},(qA[CXUoOSrRiZI]),(.+){1,}:" Local $sString = "# aprsc 2.1.13-g79b6c3e" & @CRLF & _ "# logresp WV6L unverified, server FIRST" & @CRLF & _ "KG6DMY-9>APAT51,RCHFLD,WIDE1*,qAR,ABAJO:!3846.80N/11205.07W&261/000/A=005347I'm Charles. 146.640 - pl 100" & @CRLF & _ "N3FAA>APRS,TCPIP*,qAC,AMBCWOP-2:@062011z3447.10N/11816.47W_049/001g002t053r000p001P001h57b10216L412AmbientCWOP.com" & @CRLF & _ "KM6WSX>APX219,N6EX-4*,qAR,KELLER:=3405.98N/11736.25W-/A=001105/" & @CRLF & _ "K7EDT-S>APDG01,TCPIP*,qAC,K7EDT-GS:;K7EDT B *062011z3322.32ND11148.72WaRNG0001/A=000010 440 Voice 443.12500MHz +0.0000MHz" & @CRLF & _ "RUTH>APNX02,WIDE3-3,qAR,N7GWT:!3918.75NS11505.39W#PHG58306/W3,NVn,N7GWT, Kimberly Pk, Nv" & @CRLF & _ "KD6FEE>APFII0,qAC,APRSFI:@201141h3343.14N/11747.18W[178/000/A=000108Stormprobe | KD6FEE@arrl.net!w5X!" & @CRLF & _ "XE2BNC-1>APMI06,WIDE2-2,qAR,XE2SI-10:@070122z3218.82N/11639.92WnPHG59304/CREBC Cerro Bola " & @CRLF & _ "N4RDZ-9>S3SWXY,W7DXJ-12,WIDE1,W6SCE-11*,WIDE2,qAR,N2GTR-2:`*)p{k>/`"7/}_%" & @CRLF & _ "SQUAW>APN391,qAO,PVALY:!3428.16NS11152.56W#PHG3000/W3,AZn SQUAW PEAK DIGI 6479 FT W7EI" & @CRLF & _ "W7JLW>APRS,TCPIP*,qAC,T2CSNGRAD:@062013z3240.80N/11425.20W_049/003g007t062r000p000P000h44b10221eCumulusDsVP" & @CRLF & _ "K6CMG-7>APDR16,TCPIP*,qAC,T2FINLAND:=3404.28N/11728.09Wu359/002/A=000973 up to no good. " & @CRLF & _ "KC6JPG-D>APDG03,TCPIP*,qAC,KC6JPG-DS:!3407.92ND11733.37W&/A=000000440 MMDVM Voice 426.50000MHz +0.0000MHz, APRS for DMRGateway" & @CRLF & _ "KG5SWO>APRS,TCPIP*,qAC,AMBCWOP-2:@062011z3803.83N/12039.19W_151/000g000t054r000p000P000h60b10251L264AmbientCWOP.com" & @CRLF & _ "K0RNA-9>S3TVSQ,WIDE1-1,WIDE2-1,qAR,AG7GK-2:`(0Vm-6k/`"8p}Encore Floors -Blue F-150 - Rich-Love,Peace,& Chicken Grease_%" & @CRLF & _ "KG6DMY-9>APAT51,RCHFLD,BACON,WIDE1*,qAR,ABAJO:!3846.80N/11205.07W&261/000/A=005347I'm Charles. 146.640 - pl 100" & @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