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
  • 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

/
/
gsi

Test String

Substitution

Processing...

Code Generator

Generated Code

#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox Local $sRegex = "(?si).*?Name: (?<name>.*?)\nversion: (?<num>.*?)\n.*?created on: (?<date>.*?)\n.*?" Local $sString = "Loading repository data..." & @CRLF & _ "Reading installed packages..." & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "Information for patch sdksp3-rpm-201406:" & @CRLF & _ "" & @CRLF & _ "Name: sdksp3-rpm-201406" & @CRLF & _ "Version: 9435" & @CRLF & _ "Arch: noarch" & @CRLF & _ "Vendor: maint-coord@suse.de" & @CRLF & _ "Status: Needed" & @CRLF & _ "Category: recommended" & @CRLF & _ "Created On: Thu Jun 26 11:27:51 2014" & @CRLF & _ "Reboot Required: No" & @CRLF & _ "Package Manager Restart Required: Yes" & @CRLF & _ "Interactive: No" & @CRLF & _ "Summary: YOU update for popt" & @CRLF & _ "Description:" & @CRLF & _ "" & @CRLF & _ "This update for RPM provides the following fixes and enhancements:" & @CRLF & _ "" & @CRLF & _ " * Add query support for the new weak dependency tags used in SLE 12." & @CRLF & _ " (bnc#884373)" & @CRLF & _ " * Remove harmful --target option passing from the configure macro." & @CRLF & _ " (bnc#870358)" & @CRLF & _ " * Disable broken ldconfig skipping code. (bnc#725478)" & @CRLF & _ "" & @CRLF & _ "Additionally, one issue was fixed in the rpm-python sub-package:" & @CRLF & _ "" & @CRLF & _ " * Return a PyLong for installsize and archivesize if a PyInt would be" & @CRLF & _ " negative. This could make createrepo(8) generate repository metadata" & @CRLF & _ " with negative sizes for some packages. (bnc#882489)" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "Provides:" & @CRLF & _ "patch:sdksp3-rpm-201406 == 9435" & @CRLF & _ "" & @CRLF & _ "Conflicts:" & @CRLF & _ "popt-devel.x86_64 < 1.7-37.58.1" & @CRLF & _ "rpm-32bit.x86_64 < 4.4.2.3-37.58.1" & @CRLF & _ "rpm-devel.x86_64 < 4.4.2.3-37.58.1" & @CRLF & _ "Loading repository data..." & @CRLF & _ "Reading installed packages..." & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "Information for patch sdksp3-rpm-201501:" & @CRLF & _ "" & @CRLF & _ "Name: sdksp3-rpm-201501" & @CRLF & _ "Version: 10143" & @CRLF & _ "Arch: noarch" & @CRLF & _ "Vendor: maint-coord@suse.de" & @CRLF & _ "Status: Needed" & @CRLF & _ "Category: recommended" & @CRLF & _ "Created On: Fri Jan 9 08:15:33 2015" & @CRLF & _ "Reboot Required: No" & @CRLF & _ "Package Manager Restart Required: Yes" & @CRLF & _ "Interactive: No" & @CRLF & _ "Summary: Recommended update for rpm" & @CRLF & _ "Description:" & @CRLF & _ "" & @CRLF & _ "This update for "rpm" fixes installation of packages when there are spaces" & @CRLF & _ "in the path or file name and the option "--noglob" is used." & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "Provides:" & @CRLF & _ "patch:sdksp3-rpm-201501 == 10143" & @CRLF & _ "" & @CRLF & _ "Conflicts:" & @CRLF & _ "popt-devel.x86_64 < 1.7-37.62.9" & @CRLF & _ "rpm-32bit.x86_64 < 4.4.2.3-37.62.9" & @CRLF & _ "rpm-devel.x86_64 < 4.4.2.3-37.62.9" & @CRLF & _ "Loading repository data..." & @CRLF & _ "Reading installed packages..." & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "Information for patch sdksp3-softwaremgmt-201503:" & @CRLF & _ "" & @CRLF & _ "Name: sdksp3-softwaremgmt-201503" & @CRLF & _ "Version: 10576" & @CRLF & _ "Arch: noarch" & @CRLF & _ "Vendor: maint-coord@suse.de" & @CRLF & _ "Status: Needed" & @CRLF & _ "Category: recommended" & @CRLF & _ "Created On: Tue Apr 7 09:29:23 2015" & @CRLF & _ "Reboot Required: No" & @CRLF & _ "Package Manager Restart Required: Yes" & @CRLF & _ "Interactive: No" & @CRLF & _ "Summary: YOU update for the Software Update Stack" & @CRLF & _ "Description:" & @CRLF & _ "" & @CRLF & _ "This collective update for the Software Update Stack provides several fixes" & @CRLF & _ "and enhancements." & @CRLF & _ "" & @CRLF & _ "libsatsolver:" & @CRLF & _ "" & @CRLF & _ " * Support product end-of-life attribute. (FATE#300591)" & @CRLF & _ "" & @CRLF & _ "libzypp:" & @CRLF & _ "" & @CRLF & _ " * Improve conflict message for locked packages. (bsc#828631)" & @CRLF & _ " * Add Product::endOfLife attribute. (FATE#316172, FATE#300591)" & @CRLF & _ "" & @CRLF & _ "PackageKit:" & @CRLF & _ "" & @CRLF & _ " * When a proxy server is configured, a default route is not mandatory." & @CRLF & _ " (bsc#910462)" & @CRLF & _ "" & @CRLF & _ "rpm:" & @CRLF & _ "" & @CRLF & _ " * Allow noscripts and notriggers on verify. (bsc#803669)" & @CRLF & _ "" & @CRLF & _ "yast2-pkg-bindings:" & @CRLF & _ "" & @CRLF & _ " * Use alias from URL query parameter if present. (bsc#892431)" & @CRLF & _ "" & @CRLF & _ "zypper:" & @CRLF & _ "" & @CRLF & _ " * A date limit must ignore newer patch candidates. (bsc#919709)" & @CRLF & _ " * Show locked packages in zypper summary. (FATE#318256)" & @CRLF & _ " * Refresh plugin services on 'lr' 'ls -r' and 'ref'. (bsc#893294," & @CRLF & _ " FATE#317863)" & @CRLF & _ " * Enhance 'Digest verification failed' dialog. (FATE#315008)" & @CRLF & _ " * Add Product::endOfLife attribute. (FATE#316172, FATE#300591)" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "Provides:" & @CRLF & _ "patch:sdksp3-softwaremgmt-201503 == 10576" & @CRLF & _ "" & @CRLF & _ "Conflicts:" & @CRLF & _ "PackageKit-devel.x86_64 < 0.3.14-2.30.11" & @CRLF & _ "libpackagekit-glib10-devel.x86_64 < 0.3.14-2.30.11" & @CRLF & _ "libpackagekit-qt10.x86_64 < 0.3.14-2.30.11" & @CRLF & _ "libpackagekit-qt10-devel.x86_64 < 0.3.14-2.30.11" & @CRLF & _ "libsatsolver-devel.x86_64 < 0.17.9-0.5.2" & @CRLF & _ "libzypp-devel.x86_64 < 9.38.4-0.7.10" & @CRLF & _ "popt-devel.x86_64 < 1.7-37.63.64.1" & @CRLF & _ "rpm-32bit.x86_64 < 4.4.2.3-37.63.64.1" & @CRLF & _ "rpm-devel.x86_64 < 4.4.2.3-37.63.64.1" & @CRLF & _ "ruby-satsolver.x86_64 < 0.44.5-0.5.194" & @CRLF & _ "yast2-pkg-bindings-devel-doc.noarch < 2.17.59.2-0.8.13" & @CRLF & _ "Loading repository data..." & @CRLF & _ "Reading installed packages..." & @CRLF & _ "" Local $sSubst = "\g<name> \g<num> \g<date>\n" 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