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

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