Regular Expressions 101

Save & Share

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

Substitution

Processing...

Code Generator

Generated Code

#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox Local $sRegex = "<\/?(\d)" Local $sString = "<?xml version="1.0"?>" & @CRLF & _ "<data>" & @CRLF & _ " <client_name>Awesome Client</client_name>" & @CRLF & _ " <account_number/>" & @CRLF & _ " <date_created>02/12/2016</date_created>" & @CRLF & _ " <form_number>4126</form_number>" & @CRLF & _ " <customer_po/>" & @CRLF & _ " <terms_name>Credit Card</terms_name>" & @CRLF & _ " <date_shipped>12/31/1969</date_shipped>" & @CRLF & _ " <billing_contact_email/>" & @CRLF & _ " <billing_contact_address_line_1/>" & @CRLF & _ " <billing_contact_address_line_2/>" & @CRLF & _ " <billing_contact_address_line_3/>" & @CRLF & _ " <billing_contact_address_line_4/>" & @CRLF & _ " <billing_contact_address_city/>" & @CRLF & _ " <billing_contact_address_state>British Columbia</billing_contact_address_state>" & @CRLF & _ " <billing_contact_address_postal/>" & @CRLF & _ " <billing_contact_address_country>Canada</billing_contact_address_country>" & @CRLF & _ " <shipping_contact_address_line_1/>" & @CRLF & _ " <shipping_contact_address_line_2/>" & @CRLF & _ " <shipping_contact_address_line_3/>" & @CRLF & _ " <shipping_contact_address_line_4/>" & @CRLF & _ " <shipping_contact_address_city/>" & @CRLF & _ " <shipping_contact_address_state>British Columbia</shipping_contact_address_state>" & @CRLF & _ " <shipping_contact_address_postal/>" & @CRLF & _ " <shipping_contact_address_country>Canada</shipping_contact_address_country>" & @CRLF & _ " <billing_contact_first_name>another</billing_contact_first_name>" & @CRLF & _ " <billing_contact_last_name>client</billing_contact_last_name>" & @CRLF & _ " <client_rep_full_name>Rob Montebelli</client_rep_full_name>" & @CRLF & _ " <order_rep_full_name>Mark Graham</order_rep_full_name>" & @CRLF & _ " <job_name>77777</job_name>" & @CRLF & _ " <job_number>2620</job_number>" & @CRLF & _ " <event_type>Donor Gift</event_type>" & @CRLF & _ " <due_date>02/12/2016</due_date>" & @CRLF & _ " <shipping_method/>" & @CRLF & _ " <currency>CAD</currency>" & @CRLF & _ " <total_taxes>0.00</total_taxes>" & @CRLF & _ " <total_subtotal>1,760.16</total_subtotal>" & @CRLF & _ " <total>1,760.16</total>" & @CRLF & _ " <items>" & @CRLF & _ " <item0>" & @CRLF & _ " <taxes>" & @CRLF & _ " <0>E</0>" & @CRLF & _ " </taxes>" & @CRLF & _ " <title>1889-24</title>" & @CRLF & _ " <quantity>6</quantity>" & @CRLF & _ " <description>Carhartt (R) Signature Utility Duffel; TBD TBD</description>" & @CRLF & _ " <unit_price>159.32</unit_price>" & @CRLF & _ " </item0>" & @CRLF & _ " <item1>" & @CRLF & _ " <taxes>" & @CRLF & _ " <0>E</0>" & @CRLF & _ " </taxes>" & @CRLF & _ " <title>0022-56</title>" & @CRLF & _ " <quantity>12</quantity>" & @CRLF & _ " <description>Zoom (TM) DayTripper Sling Compu-Messenger; TBD TBD</description>" & @CRLF & _ " <unit_price>67.02</unit_price>" & @CRLF & _ " </item1>" & @CRLF & _ " </items>" & @CRLF & _ "</data>" Local $sSubst = "<number$1" 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