Regular Expressions 101

Save & Manage Regex

  • Current Version: 1
  • Save & Share
  • Community Library

Flavor

  • PCRE2 (PHP)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java
  • .NET 7.0 (C#)
  • Rust
  • PCRE (Legacy)
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests
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
Processing...

Test String

Substitution
Processing...

Code Generator

Generated Code

#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox Local $sRegex = "(?m)[\041-\176]+:" Local $sString = "From xjackh+caf_=xjackh=jrh.sh@gmail.com Wed Oct 29 03:20:52 2025" & @CRLF & _ "Return-path: <xjackh+caf_=xjackh=jrh.sh@gmail.com>" & @CRLF & _ "Envelope-to: xjackh@jrh.sh" & @CRLF & _ "Delivery-date: Wed, 29 Oct 2025 03:20:52 +0000" & @CRLF & _ "Received: from mail-wr1-f47.google.com ([209.85.221.47])" & @CRLF & _ " by glacier.mxrouting.net with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384" & @CRLF & _ " (Exim 4.98)" & @CRLF & _ " (envelope-from <xjackh+caf_=xjackh=jrh.sh@gmail.com>)" & @CRLF & _ " id 1vDwjz-0000000G5kY-0gU6" & @CRLF & _ " for xjackh@jrh.sh;" & @CRLF & _ " Wed, 29 Oct 2025 03:20:52 +0000" & @CRLF & _ "Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-42701b29a7eso271232f8f.0" & @CRLF & _ " for <xjackh@jrh.sh>; Tue, 28 Oct 2025 20:20:51 -0700 (PDT)" & @CRLF & _ "ARC-Seal: i=2; a=rsa-sha256; t=1761708050; cv=pass;" & @CRLF & _ " d=google.com; s=arc-20240605;" & @CRLF & _ " b=C7UZsXpJzrPnSJQiHi0mAcFAbVyAsGlBvcU0IQJte4IF+nItmMwEsuwnkzmiTSDJp8" & @CRLF & _ " 4O0Xys78bHJFwNByPb6f9OSblqs6HGOjwBPqK1iaQyOjjtPJaHvRuK9DVKOY1JJxV1Fw" & @CRLF & _ " lSNrIxRQnUrm4C5fVzHWfRoN736l4Jzil+RzUlEGNiuVNIa2XcN0owUaNijfdDgIVV2T" & @CRLF & _ " VDz1966jTfmGvG4iKL6qd937Hdl4spHRE/XK2cHWWucBTKYuri7t0ib8UTZaoMxXPVgp" & @CRLF & _ " TXRzK+9j8yvNm/spUvz36imPloWfr8DJlL57/UVJS7SZl+ydAJwKtjAyfacxZgNxm+02" & @CRLF & _ " Z7xw==" & @CRLF & _ "ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605;" & @CRLF & _ " h=feedback-id:mime-version:subject:to:from:date:dkim-signature" & @CRLF & _ " :message-id:delivered-to;" & @CRLF & _ " bh=vRmniYCYXVIAiIJPuHtSj29f2zefOZCS2+LWmfWbcZw=;" & @CRLF & _ " fh=JwjRhZczYpEeTfVk3p/cxXR1iOjJ+oSrnKTBEmypBlc=;" & @CRLF & _ " b=GZZFdTjV88vU87OjprcOIBM/vEt5u6H+z5i7Yp+wvtzQkgMm6yUSEWjdUhaB3MGdXh" & @CRLF & _ " 1reAy/lDqEsH7nRaS/l1HfICe50G6qAMm5z36AoJ0dFU6j9hp5/CeWy3Dm22MjWYZb5h" & @CRLF & _ " L/7RXOCCLGdiGIbDyfy63hslLe4rfM4nLYbwnfiUs/Y9yBoeLPb4UZoOLcljMreSjvRB" & @CRLF & _ " E1fQSNHGa3vj0llVqU8JngotTcZ9KJ6lpUiDe4dDN9bsRQz0YlK5iyRFiVvfMQl+teH9" & @CRLF & _ " Kznj0PBRSE71Iw8HrqJx3/XXKJhArAtedzmbKhErxvGHYbbIRHPvXL29rx5iVGkfaVWJ" & @CRLF & _ " XyVQ==;" & @CRLF & _ " darn=jrh.sh" & @CRLF & _ "ARC-Authentication-Results: i=2; mx.google.com;" & @CRLF & _ " dkim=pass header.i=@deals.aliexpress.com header.s=aliyun-ap-southeast-1 header.b=NGVAU49w;" & @CRLF & _ " spf=pass (google.com: domain of ae-report.ae0@deals.aliexpress.com designates 8.219.33.24 as permitted sender) smtp.mailfrom=ae-report.ae0@deals.aliexpress.com;" & @CRLF & _ " dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=deals.aliexpress.com" & @CRLF & _ "X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;" & @CRLF & _ " d=1e100.net; s=20230601; t=1761708050; x=1762312850;" & @CRLF & _ " h=feedback-id:mime-version:subject:to:from:date:dkim-signature" & @CRLF & _ " :message-id:delivered-to:x-forwarded-for:x-forwarded-to" & @CRLF & _ " :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;" & @CRLF & _ " bh=vRmniYCYXVIAiIJPuHtSj29f2zefOZCS2+LWmfWbcZw=;" & @CRLF & _ " b=CDKe4dMV3sXqRJogOxq5XlcgiFB9wEhUjF67Iy/zX6u1wdB6aysXIc0a0fTfkjfs5F" & @CRLF & _ " /SWPpkGXt3zcPw03C9dv55+3GGrILLbPAc3Br4Ijrb1Ts/900yfIwRIpCiJt8UVw3Jzm" & @CRLF & _ " It9ggGW9L7Oaml4//pLBTJ95bpvSzfl4DGANsKl8bD5hWqW+pP0VdscG+vLuujb51y5p" & @CRLF & _ " gux0KkJBOTQI3hqPiXJbnsZRtr7CoK5ujZiKS6FgpKI2VjZFcZLXWO+cdT00bvQgbkSf" & @CRLF & _ " bfpMDope4CHeO4GOrYDgZWRUUz8nP+wuTkRQzJ2hkXkjrFafvJc6ZmhT6IDhiuetQQWX" & @CRLF & _ " Wszg==" & @CRLF & _ "X-Forwarded-Encrypted: i=2; AJvYcCXtwG/Ac4/Y20TzZ0+EFUXLkbbe8dqyXqYZy8yO1H8ppFI9jwaeAF04VJzefACzq4qh7PISS68=@jrh.sh" & @CRLF & _ "X-Gm-Message-State: AOJu0YxEYfh4YdjC/SBefQvWNRIR5ljkN7QoR9DoBTV2PkBlgGwNWlZM" & @CRLF & _ " xp5L/IhMgTVIK1kKCisMKdt9eNAGhV3qPQa4em7FfMQrIDyvsnetGZMQ+J6XCrw7YZ0f4gP+6TL" & @CRLF & _ " K4xcJFlHY03oMoFkcmgMo5YPdKWCcGVOyyJ7vWZu6RALsQMKn1xZgu+lZEKrViQ==" & @CRLF & _ "X-Received: by 2002:a05:6000:24c9:b0:425:86b1:113a with SMTP id ffacd0b85a97d-429a81ea702mr5073556f8f.16.1761708050052;" & @CRLF & _ " Tue, 28 Oct 2025 20:20:50 -0700 (PDT)" & @CRLF & _ "X-Forwarded-To: xjackh@jrh.sh" & @CRLF & _ "X-Forwarded-For: xjackh@gmail.com xjackh@jrh.sh" & @CRLF & _ "Delivered-To: xjackh@gmail.com" & @CRLF & _ "Received: by 2002:a05:6000:dc2:b0:427:632:4190 with SMTP id dw2csp1860918wrb;" & @CRLF & _ " Tue, 28 Oct 2025 20:20:48 -0700 (PDT)" & @CRLF & _ "X-Google-Smtp-Source: AGHT+IHUfXjUwENcjOwEXkBNZOE2CifXw4FktUj3SSaAtc+U0MfF8DPDHBUVz0mkDFonGhHjgnS7" & @CRLF & _ "X-Received: by 2002:a05:6a20:9150:b0:33f:df99:11ed with SMTP id adf61e73a8af0-34653337a2dmr1903058637.24.1761708048038;" & @CRLF & _ " Tue, 28 Oct 2025 20:20:48 -0700 (PDT)" & @CRLF & _ "ARC-Seal: i=1; a=rsa-sha256; t=1761708048; cv=none;" & @CRLF & _ " d=google.com; s=arc-20240605;" & @CRLF & _ " b=CdPvEAo+IvoLoWxQdCxBXW+3puMPQkidzNrcardKvVoYuE4S/Ml4i6d6aUICqc4ydP" & @CRLF & _ " 9BaC/lyHBS/VgcanoGHrzHq0OJOQr3fJvWe7elAO6B9PFFriRvB1KLukyhXQlvGgiKOw" & @CRLF & _ " Cq8rARb7QF8Mki/I4B7IUYfQg3c0VSo8sWKhTaBJ4v+V2hmMS3pyXGgUvMrDNKW1p+fg" & @CRLF & _ " hLUtFH38ruXgN+KUbeq4JrzsHzANNwOjWsJLa81Rtw3ljq3v2qMnmxMjdm5moN4gDPMI" & @CRLF & _ " agu0LM2pZDh15mV7EE0c/uC1z0Yqr7/IUdhkT+AvFdT0EpVMm5jIRpxLL5JMgoPnd2OX" & @CRLF & _ " 1Seg==" & @CRLF & _ "ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605;" & @CRLF & _ " h=feedback-id:mime-version:subject:to:from:date:dkim-signature" & @CRLF & _ " :message-id;" & @CRLF & _ " bh=vRmniYCYXVIAiIJPuHtSj29f2zefOZCS2+LWmfWbcZw=;" & @CRLF & _ " fh=qR5+LTh/3Ua36ecBQvpnRfVCaHh2O6Cn2Gj2Y9qDsqY=;" & @CRLF & _ " b=EhytWeDKTraXyOId3sr9UHnlMtINFtjNLWzOC0VgAM4S0utspBQXKDSS4rdPpUGFxU" & @CRLF & _ " m6zAnV+d2XYEnhQFOmU9hcyukxfkh3Ry3aBtnLcgVzpIEKCHo56ZGnoaPZYAybpd+nyX" & @CRLF & _ " mMiAMyEPASbRmpUaJ6Y6QhbYvujTVx+kDPAYbQdVxmuFRW6HxeC8sShWe86qoLt8ey+e" & @CRLF & _ " kxMAGyuQLe8N2Pzfax3aQYAQShI9Sz3b9gRad1xjlThCQF5TrRhxOrP2gdZiVfM4PJzm" & @CRLF & _ " UmIpARLVfyE5ArlWf8RXtGq8tt4hplTeSmBO0ZDxUm3PucYZz7S/9ahqO8fDATnTGnLT" & @CRLF & _ " oJ6Q==;" & @CRLF & _ " dara=google.com" & @CRLF & _ "ARC-Authentication-Results: i=1; mx.google.com;" & @CRLF & _ " dkim=pass header.i=@deals.aliexpress.com header.s=aliyun-ap-southeast-1 header.b=NGVAU49w;" & @CRLF & _ " spf=pass (google.com: domain of ae-report.ae0@deals.aliexpress.com designates 8.219.33.24 as permitted sender) smtp.mailfrom=ae-report.ae0@deals.aliexpress.com;" & @CRLF & _ " dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=deals.aliexpress.com" & @CRLF & _ "Received: from out33-24.sg.b.dm.aliyun.com (out33-24.sg.b.dm.aliyun.com. [8.219.33.24])" & @CRLF & _ " by mx.google.com with ESMTPS id 41be03b00d2f7-b71f4ba78d2si6202184a12.1047.2025.10.28.20.20.46" & @CRLF & _ " for <xjackh@gmail.com>" & @CRLF & _ " (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);" & @CRLF & _ " Tue, 28 Oct 2025 20:20:48 -0700 (PDT)" & @CRLF & _ "Received-SPF: pass (google.com: domain of ae-report.ae0@deals.aliexpress.com designates 8.219.33.24 as permitted sender) client-ip=8.219.33.24;" & @CRLF & _ "Authentication-Results: mx.google.com;" & @CRLF & _ " dkim=pass header.i=@deals.aliexpress.com header.s=aliyun-ap-southeast-1 header.b=NGVAU49w;" & @CRLF & _ " spf=pass (google.com: domain of ae-report.ae0@deals.aliexpress.com designates 8.219.33.24 as permitted sender) smtp.mailfrom=ae-report.ae0@deals.aliexpress.com;" & @CRLF & _ " dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=deals.aliexpress.com" & @CRLF & _ "Message-ID: <69018810.050a0220.cfe87.f51eSMTPIN_ADDED_BROKEN@mx.google.com>" & @CRLF & _ "X-Google-Original-Message-ID: <9871biz_add_cart:0:0_579222405$432bfbabec63491d8a77746119e0e945@deals.aliexpress.com>" & @CRLF & _ "X-AliDM-RcptTo: eGphY2toQGdtYWlsLmNvbQ==" & @CRLF & _ "DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed;" & @CRLF & _ " d=deals.aliexpress.com; s=aliyun-ap-southeast-1;" & @CRLF & _ " t=1761708046; h=Date:From:To:Message-ID:Subject:MIME-Version:Content-Type;" & @CRLF & _ " bh=vRmniYCYXVIAiIJPuHtSj29f2zefOZCS2+LWmfWbcZw=;" & @CRLF & _ " b=NGVAU49w8Ms5d9xgiygPUkwxi9ZflULR710SmP0ZJbigzvY/AUmUwWI24T7cwBeEVFV2P3O73AkfiWeCDqxs4oxCviAkM/2TLMn9+60TCpZ8nbvv3TRdrnikjzmDui4qO09YbehtghFhVksQKhGTDEJleZ0caAV1ZWUMaWtfl/o=" & @CRLF & _ "Received: from ae-ut-crab-s033065010130.sg52(mailfrom:ae-report.ae0@deals.aliexpress.com fp:SMTPD_4w3hQ..1XR5 cluster:dm-ay35sg-a)" & @CRLF & _ " by smtp.aliyun-inc.com(127.0.0.1);" & @CRLF & _ " Wed, 29 Oct 2025 11:20:45 +0800" & @CRLF & _ "X-EnvId: 8000000150423353160" & @CRLF & _ "Date: Tue, 28 Oct 2025 20:20:45 -0700 (PDT)" & @CRLF & _ "From: AliExpress <ae-report.ae0@deals.aliexpress.com>" & @CRLF & _ "To: xjackh@gmail.com" & @CRLF & _ "MIME-Version: 1.0" & @CRLF & _ "Content-Type: multipart/mixed; " & @CRLF & _ " boundary="----=_Part_1025839_1127131696.1761708045971"" & @CRLF & _ "X-250ok-CID: 42c31aa6232f4990b1f5c6437dc13f99" & @CRLF & _ "Feedback-ID: trigger_biz_add_cart-0:ae-report.ae0@deals.aliexpress.com:S-100001:151973" & @CRLF & _ "X-DKIM: signer='deals.aliexpress.com' status='fail' reason='signature_incorrect'" & @CRLF & _ "DKIMCheck: Server failed DKIM test, 50 Spam score" & @CRLF & _ "X-Spam-Score: 6.2 (++++++)" & @CRLF & _ "X-Spam-Report: Spam detection software, running on the system "glacier.mxrouting.net", has" & @CRLF & _ " performed the tests listed below against this email." & @CRLF & _ " Information: https://mxroutedocs.com/directadmin/spamfilters/" & @CRLF & _ " ---" & @CRLF & _ " Content analysis details: (6.2 points)" & @CRLF & _ " ---" & @CRLF & _ " pts rule name description" & @CRLF & _ " ---- ---------------------- -----------------------------------------" & @CRLF & _ " 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked." & @CRLF & _ " See" & @CRLF & _ " http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block" & @CRLF & _ " for more information." & @CRLF & _ " [URI: aliexpress.com]" & @CRLF & _ " [URI: mmstat.com]" & @CRLF & _ " [URI: fonts.googleapis.com]" & @CRLF & _ " 0.0 RCVD_IN_DNSWL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to DNSWL" & @CRLF & _ " was blocked. See" & @CRLF & _ " http://wiki.apache.org/spamassassin/DnsBlocklists#DnsBlocklists-dnsbl-block" & @CRLF & _ " for more information." & @CRLF & _ " [209.85.221.47 listed in list.dnswl.org]" & @CRLF & _ " 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record" & @CRLF & _ " 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid" & @CRLF & _ " 0.0 ARC_SIGNED Message has a ARC signature" & @CRLF & _ " 0.0 ARC_VALID Message has a valid ARC signature" & @CRLF & _ " 0.1 DKIM_INVALID DKIM or DK signature exists, but is not valid" & @CRLF & _ " 0.0 KAM_DMARC_STATUS Test Rule for DKIM or SPF Failure with Strict" & @CRLF & _ " Alignment" & @CRLF & _ " 1.5 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail" & @CRLF & _ " domains are different" & @CRLF & _ " 1.0 HTML_FONT_LOW_CONTRAST BODY: HTML font color similar or identical to" & @CRLF & _ " background" & @CRLF & _ " 1.5 HTML_MESSAGE BODY: HTML included in message" & @CRLF & _ " 2.0 MIME_HTML_ONLY BODY: Message only has text/html MIME parts" & @CRLF & _ " 0.0 HTML_IMAGE_RATIO_04 BODY: HTML has a low ratio of text to image area" & @CRLF & _ " 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay" & @CRLF & _ "X-Old-Subject:Good choice, your faves await!" & @CRLF & _ "Subject:Good choice, your faves await!" & @CRLF & _ "X-Spam-Status: Yes, score=6.2, +20 total spam score" & @CRLF & _ "SpamTally: Final spam score: 132" & @CRLF & _ "" & @CRLF & _ "------=_Part_1025839_1127131696.1761708045971" & @CRLF & _ "Content-Type: text/html;charset=utf-8" & @CRLF & _ "Content-Transfer-Encoding: quoted-printable" & @CRLF & _ "" & @CRLF & _ "<-- BODY SNIPPED HERE -->" & @CRLF & _ "" & @CRLF & _ "------=_Part_1025839_1127131696.1761708045971--" Local $sSubst = "" Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst) MsgBox($MB_SYSTEMMODAL, "Result", $sResult)

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