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
  • Match everything enclosed
    (?:...)
  • Capture everything enclosed
    (...)
  • 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{44}" Local $sString = " Found 55 barcodes:" & @CRLF & _ " 1) I2of5, Confidence: 1,00, Page 1, Rectangle: [231; 2494; 1271; 1]" & @CRLF & _ " Value: 89620000002429000411110202208291001225388559" & @CRLF & _ " 2) I2of5, Confidence: 0,50, Page 2, Rectangle: [606; 645; 219; 1]" & @CRLF & _ " Value: 3505" & @CRLF & _ " 3) I2of5, Confidence: 1,00, Page 2, Rectangle: [266; 2478; 1270; 1]" & @CRLF & _ " Value: 89650000002409000411110202207291001225323761" & @CRLF & _ " 4) I2of5, Confidence: 0,50, Page 3, Rectangle: [2058; 1985; 192; 1]" & @CRLF & _ " Value: 5862" & @CRLF & _ " 5) I2of5, Confidence: 0,50, Page 3, Rectangle: [260; 2485; 1270; 1]" & @CRLF & _ " Value: 89680000002429000411110202208291001225388504" & @CRLF & _ " 6) I2of5, Confidence: 0,50, Page 4, Rectangle: [1544; 1229; 280; 1]" & @CRLF & _ " Value: 0316" & @CRLF & _ " 7) I2of5, Confidence: 0,50, Page 4, Rectangle: [279; 2487; 1271; 1]" & @CRLF & _ " Value: 89620000002429000411110202208291001225388502" & @CRLF & _ " 8) I2of5, Confidence: 1,00, Page 5, Rectangle: [258; 2491; 1271; 1]" & @CRLF & _ " Value: 89610000002429000411110202208291001225388499" & @CRLF & _ " 9) I2of5, Confidence: 0,50, Page 6, Rectangle: [237; 2601; 1271; 1]" & @CRLF & _ " Value: 89660000002553300411110202208291001225310933" & @CRLF & _ " 10) I2of5, Confidence: 0,50, Page 7, Rectangle: [575; 1557; 220; 1]" & @CRLF & _ " Value: 1555" & @CRLF & _ " 11) I2of5, Confidence: 0,50, Page 7, Rectangle: [239; 2508; 1270; 1]" & @CRLF & _ " Value: 89670000002429000411110202208291001225388552" & @CRLF & _ " 12) I2of5, Confidence: 0,50, Page 8, Rectangle: [254; 2413; 1270; 1]" & @CRLF & _ " Value: 89650000002429000411110202208291001225388497" & @CRLF & _ " 13) I2of5, Confidence: 0,50, Page 9, Rectangle: [584; 1563; 226; 1]" & @CRLF & _ " Value: 1545" & @CRLF & _ " 14) I2of5, Confidence: 0,50, Page 9, Rectangle: [237; 2515; 1271; 1]" & @CRLF & _ " Value: 89610000002429000411110202208291001225388480" & @CRLF & _ " 15) I2of5, Confidence: 0,50, Page 10, Rectangle: [575; 655; 228; 1]" & @CRLF & _ " Value: 2555" & @CRLF & _ " 16) I2of5, Confidence: 0,50, Page 10, Rectangle: [578; 1553; 226; 1]" & @CRLF & _ " Value: 1555" & @CRLF & _ " 17) I2of5, Confidence: 1,00, Page 10, Rectangle: [236; 2497; 1270; 1]" & @CRLF & _ " Value: 89620000002429000411110202208291001225388540" & @CRLF & _ " 18) I2of5, Confidence: 0,50, Page 11, Rectangle: [231; 2475; 1266; 1]" & @CRLF & _ " Value: 89680000003888000411110202208191001225366638" & @CRLF & _ " 19) I2of5, Confidence: 0,50, Page 12, Rectangle: [231; 2473; 1266; 1]" & @CRLF & _ " Value: 89680000003888000411110202208191001225366662" & @CRLF & _ " 20) I2of5, Confidence: 0,50, Page 13, Rectangle: [1517; 364; 280; 1]" & @CRLF & _ " Value: 0316" & @CRLF & _ " 21) I2of5, Confidence: 0,50, Page 13, Rectangle: [619; 614; 319; 1]" & @CRLF & _ " Value: 797113" & @CRLF & _ " 22) I2of5, Confidence: 0,50, Page 13, Rectangle: [264; 2539; 1265; 1]" & @CRLF & _ " Value: 89600000002429000411110202208261001225388255" & @CRLF & _ " 23) I2of5, Confidence: 1,00, Page 14, Rectangle: [228; 2523; 641; 1]" & @CRLF & _ " Value: 8968000000281200041111" & @CRLF & _ " 24) I2of5, Confidence: 1,00, Page 14, Rectangle: [228; 2526; 815; 1]" & @CRLF & _ " Value: 8968000000281200041111020220" & @CRLF & _ " 25) I2of5, Confidence: 0,50, Page 14, Rectangle: [228; 2533; 1214; 1]" & @CRLF & _ " Value: 896800000028120004111102022082610012253881" & @CRLF & _ " 26) I2of5, Confidence: 0,50, Page 14, Rectangle: [228; 2535; 1263; 1]" & @CRLF & _ " Value: 89680000002812000411110202208261001225388113" & @CRLF & _ " 27) I2of5, Confidence: 0,50, Page 15, Rectangle: [275; 2539; 1264; 1]" & @CRLF & _ " Value: 89660000002429000411110202208261001225388115" & @CRLF & _ " 28) I2of5, Confidence: 1,00, Page 16, Rectangle: [249; 2454; 1263; 1]" & @CRLF & _ " Value: 89610000002429000411110202208291001225388512" & @CRLF & _ " 29) I2of5, Confidence: 0,50, Page 17, Rectangle: [581; 679; 228; 1]" & @CRLF & _ " Value: 2505" & @CRLF & _ " 30) I2of5, Confidence: 1,00, Page 17, Rectangle: [581; 1548; 209; 1]" & @CRLF & _ " Value: 3759" & @CRLF & _ " 31) I2of5, Confidence: 0,50, Page 17, Rectangle: [240; 2622; 1263; 1]" & @CRLF & _ " Value: 89600000000971600411110202208291001225388554" & @CRLF & _ " 32) I2of5, Confidence: 0,50, Page 18, Rectangle: [1502; 1192; 279; 1]" & @CRLF & _ " Value: 0316" & @CRLF & _ " 33) I2of5, Confidence: 1,00, Page 18, Rectangle: [243; 2376; 1263; 1]" & @CRLF & _ " Value: 89610000003037000411110202208291001225388574" & @CRLF & _ " 34) I2of5, Confidence: 0,50, Page 19, Rectangle: [1484; 1229; 279; 1]" & @CRLF & _ " Value: 0316" & @CRLF & _ " 35) I2of5, Confidence: 0,50, Page 19, Rectangle: [224; 2454; 1263; 1]" & @CRLF & _ " Value: 89690000002429000411110202208291001225388773" & @CRLF & _ " 36) I2of5, Confidence: 0,50, Page 20, Rectangle: [276; 2536; 1262; 1]" & @CRLF & _ " Value: 89650000002429000411110202208291001225388812" & @CRLF & _ " 37) I2of5, Confidence: 0,50, Page 21, Rectangle: [590; 1578; 225; 1]" & @CRLF & _ " Value: 2505" & @CRLF & _ " 38) I2of5, Confidence: 0,50, Page 21, Rectangle: [242; 2566; 1263; 1]" & @CRLF & _ " Value: 89600000002510000411110202208291001225388894" & @CRLF & _ " 39) I2of5, Confidence: 0,50, Page 22, Rectangle: [576; 1500; 228; 1]" & @CRLF & _ " Value: 1505" & @CRLF & _ " 40) I2of5, Confidence: 0,50, Page 22, Rectangle: [234; 2451; 1263; 1]" & @CRLF & _ " Value: 89620000002429000411110202208291001225388936" & @CRLF & _ " 41) I2of5, Confidence: 1,00, Page 23, Rectangle: [224; 2457; 1263; 1]" & @CRLF & _ " Value: 89610000002892000411110202208291001225388743" & @CRLF & _ " 42) I2of5, Confidence: 0,50, Page 24, Rectangle: [575; 670; 225; 1]" & @CRLF & _ " Value: 3505" & @CRLF & _ " 43) I2of5, Confidence: 0,50, Page 24, Rectangle: [573; 1578; 225; 1]" & @CRLF & _ " Value: 3595" & @CRLF & _ " 44) I2of5, Confidence: 0,50, Page 24, Rectangle: [230; 2533; 1263; 1]" & @CRLF & _ " Value: 89630000002579000411110202208291001225388890" & @CRLF & _ " 45) I2of5, Confidence: 0,50, Page 25, Rectangle: [584; 1583; 223; 1]" & @CRLF & _ " Value: 2545" & @CRLF & _ " 46) I2of5, Confidence: 0,50, Page 25, Rectangle: [240; 2536; 1263; 1]" & @CRLF & _ " Value: 89660000002429000411110202208291001225389825" & @CRLF & _ " 47) I2of5, Confidence: 0,50, Page 26, Rectangle: [240; 2539; 1265; 1]" & @CRLF & _ " Value: 89610000002429000411110202208291001225389941" & @CRLF & _ " 48) I2of5, Confidence: 1,00, Page 27, Rectangle: [1814; 312; 226; 1]" & @CRLF & _ " Value: 829571" & @CRLF & _ " 49) I2of5, Confidence: 0,50, Page 27, Rectangle: [231; 2382; 1263; 1]" & @CRLF & _ " Value: 89640000003037000411110202208291001225388431" & @CRLF & _ " 50) I2of5, Confidence: 0,50, Page 28, Rectangle: [231; 2533; 1263; 1]" & @CRLF & _ " Value: 89660000003037000411110202208291001225388307" & @CRLF & _ " 51) I2of5, Confidence: 0,50, Page 29, Rectangle: [582; 1349; 159; 1]" & @CRLF & _ " Value: 4416" & @CRLF & _ " 52) I2of5, Confidence: 0,50, Page 29, Rectangle: [237; 2455; 1265; 1]" & @CRLF & _ " Value: 89670000003037000411110202208291001225390079" & @CRLF & _ " 53) I2of5, Confidence: 0,50, Page 30, Rectangle: [1932; 528; 140; 1]" & @CRLF & _ " Value: 0884" & @CRLF & _ " 54) I2of5, Confidence: 0,50, Page 30, Rectangle: [269; 552; 136; 1]" & @CRLF & _ " Value: 8222" & @CRLF & _ " 55) I2of5, Confidence: 0,50, Page 30, Rectangle: [231; 2527; 1265; 1]" & @CRLF & _ " Value: 89670000003012000411110202208291001225390108" & @CRLF & _ "" & @CRLF & _ " Decoding took: 1,705 seconds." & @CRLF & _ " Preparations: 1,232 seconds." & @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