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

/
/
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 = "\s*<Title\svodBackOfficeId=\"([^\s]*)">" Local $sString = "<?xml version="1.0" encoding="utf-8"?>" & @CRLF & _ "<Titles xmlns="urn:eventis:prodis:onlineapi:2.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">" & @CRLF & _ " <Title vodBackOfficeId="00181253-684f-4911-92ab-91859bc4402a">" & @CRLF & _ " <IngestId>1001_00000000071p1</IngestId>" & @CRLF & _ " <Name>Superbabies: Baby Geniuses 2 71</Name>" & @CRLF & _ " <Description>A group of smart-talking toddlers find themselves at the center of a media moguls experiment to crack the code to baby talk. The toddlers must race against time for the sake of babies everywhere.</Description>" & @CRLF & _ " <ContentProvider>Arrivo</ContentProvider>" & @CRLF & _ " <CurrentTitleType>Feature</CurrentTitleType>" & @CRLF & _ " <IsApp>false</IsApp>" & @CRLF & _ " <Assets>" & @CRLF & _ " <Asset vodBackOfficeId="dc640b52-3067-4ba2-8506-474996126089" encodingProfileCode="Cable"/>" & @CRLF & _ " <Asset vodBackOfficeId="0a36f3c4-1484-4631-be26-f01a955966ae" encodingProfileCode="Orion"/>" & @CRLF & _ " <Asset vodBackOfficeId="00a0cca8-9d09-4048-bf17-e51b63bb1491" encodingProfileCode="Widevine"/>" & @CRLF & _ " </Assets>" & @CRLF & _ " <MetadataIngestId>1001_00000000071p1</MetadataIngestId>" & @CRLF & _ " </Title>" & @CRLF & _ " <Title vodBackOfficeId="c4289c39-b92f-49c5-9a45-bc6eaf7b8393">" & @CRLF & _ " <IngestId>9110_00000000175p1</IngestId>" & @CRLF & _ " <Name>SmartRec Test VOD 1</Name>" & @CRLF & _ " <Description>The Tramp cares for an abandoned child, but events put that relationship in jeopardy. Dennis</Description>" & @CRLF & _ " <ContentProvider>Arrivo</ContentProvider>" & @CRLF & _ " <CurrentTitleType>Feature</CurrentTitleType>" & @CRLF & _ " <IsApp>false</IsApp>" & @CRLF & _ " <Assets>" & @CRLF & _ " <Asset vodBackOfficeId="39779bf2-800f-4821-8d43-b42dffe155f9" encodingProfileCode="Cable"/>" & @CRLF & _ " <Asset vodBackOfficeId="9c90a157-875e-4737-936e-3d34b60a6b61" encodingProfileCode="Orion"/>" & @CRLF & _ " <Asset vodBackOfficeId="13fb314b-332c-4633-9334-d294f72e370b" encodingProfileCode="Widevine"/>" & @CRLF & _ " </Assets>" & @CRLF & _ " <MetadataIngestId>9110_00000000175p1</MetadataIngestId>" & @CRLF & _ " </Title>" & @CRLF & _ " <Title vodBackOfficeId="4a8bc282-8bb8-4dce-b2d1-e2129c092d80">" & @CRLF & _ " <IngestId>seachange.com_TEST1386088695671341</IngestId>" & @CRLF & _ " <Name>Wanted</Name>" & @CRLF & _ " <Description>Doormat Wesley Gibson discovers that his recently murdered father -- who Wesley never knew -- belonged to a secret guild of assassins. After a leather-clad sexpot drafts Wesley into the society, he hones his innate killing skills and turns avenger.</Description>" & @CRLF & _ " <ContentProvider>SEAC</ContentProvider>" & @CRLF & _ " <CurrentTitleType>Feature</CurrentTitleType>" & @CRLF & _ " <IsApp>false</IsApp>" & @CRLF & _ " <Assets>" & @CRLF & _ " <Asset vodBackOfficeId="b0c8bdd7-00e3-4ce5-889b-73e708d75f03" encodingProfileCode="Cable"/>" & @CRLF & _ " </Assets>" & @CRLF & _ " <MetadataIngestId>seachange.com_TEST1386088695671341</MetadataIngestId>" & @CRLF & _ " </Title>" 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