Regular Expressions 101

Save & Share

  • Regex Version: ver. 2
  • 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

/
/
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 = "https?:\/\/(?=(?:....)?amazon|smile)(www|smile)\S+com(((?:\/(?:dp|gp)\/([A-Z0-9]+))?\S*[?&]?(?:tag=))?\S*?)(?:#)?(\w*?-\w{2})?(\S*)(#?\S*)+" Local $sString = "http://smile.amazon.com/dp/B0005ZH4QI/?tag=#menasheh02-20&psc=1&smid=ATVPDKIKX0DER" & @CRLF & _ "http://www.amazon.com/gp/family/signup/info/?ie=UTF8&camp=1789&creative=9325&linkCode=ur2&ref_type=generic&refcust=5FNWKEJKP63HFBSY6JGLXL4XIQ&tag=menasheh02-20&linkId=HR76ZTGJKWO5ED2N" & @CRLF & _ "http://www.amazon.com/gp/redirect.html?ie=UTF8&location=https%3A%2F%2Fwww.amazon.com%2Fgp%2Fsubscribe-and-save%2Fmanager%2Fviewsubscriptions%3Fie%3DUTF8%26ref_%3Dya%255FT15%255F33&tag=menasheh02-20&linkCode=ur2&camp=1789&creative=390957" & @CRLF & _ "http://www.amazon.com/gp/student/signup/info?ie=UTF8&refcust=7EATHY4IXOFTTEMLIHVC3YL6DI&ref_type=generic" & @CRLF & _ "http://www.amazon.com/gp/video/primesignup?tag=menasheh02-20" & @CRLF & _ "https://smile.amazon.com/dp/B0005ZH4QI/?tag=menasheh02-20&psc=1&smid=ATVPDKIKX0DER" & @CRLF & _ "https://smile.amazon.com/s/ref=s9_acss_gb_cg_HTLLPCGB_3d1?fst=as%3Aoff&rh=n%3A165793011%2Cn%3A!2334111011%2Cn%3A!2334173011%2Cn%3A15539865011%2Cp_n_age_range%3A165936011%2Cp_72%3A1248963011&bbn=15539865011&ie=UTF8&qid=1476851901&rnid=1248961011&pf_rd_m=ATVPDKIKX0DER&pf_rd_s=events-center-c-4&pf_rd_r=8MKN8SY6C5ZP4NC1C0RB&pf_rd_t=701&pf_rd_p=e4acec8d-70de-466a-be44-05291b40a5d4&pf_rd_i=HTL_desktop" & @CRLF & _ "https://www.amazon.com/b/ref=s9_acss_gb_cg_HTLLPCGB_11a1?node=13521759011&pf_rd_m=ATVPDKIKX0DER&pf_rd_s=events-center-c-4&pf_rd_r=8MKN8SY6C5ZP4NC1C0RB&pf_rd_t=701&pf_rd_p=e4acec8d-70de-466a-be44-05291b40a5d4&pf_rd_i=HTL_desktop" & @CRLF & _ "https://www.amazon.com/Doctor-Vortex-Manipulator-Sonic-Screwdriver/dp/B001PR1ZII/ref=gbph_tit_e-7_fb02_fc8a0d34?smid=AOUT97QIB451U&pf_rd_p=8e268714-ad3d-444b-b0df-d51d8825fb02&pf_rd_s=events-center-c-7&pf_rd_t=701&pf_rd_i=HTL_desktop&pf_rd_m=ATVPDKIKX0DER&pf_rd_r=8MKN8SY6C5ZP4NC1C0RB" & @CRLF & _ "https://www.amazon.com/dp/B0005ZH4QI/?tag=menasheh02-20&psc=1&smid=ATVPDKIKX0DER" & @CRLF & _ "https://www.amazon.com/gp/coupon/skippy-baking-sale/A2UI00T2I5JAV3?ie=UTF8&heroAsin=B0005ZH4QI&source=grid_db_13285418011&pf_rd_p=782d30de-8b22-4b3d-9009-0f7a0cb995d3&pf_rd_s=merchandised-search-3&pf_rd_t=Landing&pf_rd_i=13285418011&pf_rd_m=ATVPDKIKX0DER&pf_rd_r=PPNJHXVZRMM4XP9KXGGG" & @CRLF & _ "https://www.amazon.com/Monster-High-School-Playset/dp/B006O6F932/ref=gbph_tit_e-7_fb02_85d3d028?smid=A3CXJV2JYTL237&pf_rd_p=8e268714-ad3d-444b-b0df-d51d8825fb02&pf_rd_s=events-center-c-7&pf_rd_t=701&pf_rd_i=HTL_desktop&pf_rd_m=ATVPDKIKX0DER&pf_rd_r=8MKN8SY6C5ZP4NC1C0RB" & @CRLF & _ "https://www.amazon.com/s/ref=s9_acss_gb_cg_HTLLPCGB_3d1?fst=as%3Aoff&rh=n%3A165793011%2Cn%3A!2334111011%2Cn%3A!2334173011%2Cn%3A15539865011%2Cp_n_age_range%3A165936011%2Cp_72%3A1248963011&bbn=15539865011&ie=UTF8&qid=1476851901&rnid=1248961011&pf_rd_m=ATVPDKIKX0DER&pf_rd_s=events-center-c-4&pf_rd_r=8MKN8SY6C5ZP4NC1C0RB&pf_rd_t=701&pf_rd_p=e4acec8d-70de-466a-be44-05291b40a5d4&pf_rd_i=HTL_desktop" & @CRLF & _ "https://www.google.com/search?safe=active&site=&source=hp&q=bad+regex&oq=bad+regex&gs_l=hp.3..0j0i22i30k1l9.724.2089.0.2265.10.9.0.0.0.0.269.1091.0j4j2.6.0....0...1c.1.64.hp..4.5.821.0..0i20k1j0i131k1j0i10k1.k62wRudUpsw" & @CRLF & _ "https://sellercentral.amazon.com/B53C945A8D?randomstuff=34341&otherrandomstuff=2" 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