Regular Expressions 101

Save & Share

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

/
/
gm

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 = "(?m)1_ (?<Chapter_1>[^<]*)\n<(?<Benefit>[^<]*)>(?>.*\n)+\s*2_ ([^<]*)\n<(?<IfNotPerform>[^<]*)>[^.*\n+]\s*3_ (?<Chapter_3>[^<]*)\n<(?<ImplSteps>[^<]*)>.*\n+\s*" & @CRLF & _ "4_ (?<Chapter_4>[^<]*)\n<(?<AffOpco>[^<]*)>(?>.*\n)+\s*5_ (?<Chapter_5>[^<]*)\n<(?<AffServices>[^<]*)>.*\n+\s*6_ (?<Chapter_6>[^<]*)\n<(?<ServiceImpact>[^<]*)>(?>.*\n)+\s*" & @CRLF & _ "7_ (?<Chapter_7>[^<]*)\n<(?<Risks>[^<]*)>.*\n+\s*8_ (?<Chapter_8>[^<]*)\n<(?<PreImplTest>[^<]*)>.*\n+\s*9_ (?<Chapter_9>[^<]*)\n<(?<AfterImplTest>[^<]*)>.*\n+\s*" & @CRLF & _ "11_ (?<Chapter_11>[^<]*)\n<(?<Fallback>[^<]*)>.*\n+\s*12_ (?<Chapter_12>[^<]*)\n<(?<AffCI>[^<]*)>.*\n+\s*13_ (?<Chapter_13>[^<]*)\n<(?<AffDC>[^<]*)>.*\n+\s*" & @CRLF & _ "15_ (?<Chapter_15>[^<]*)\n<(?<WithinMW>[^<]*)>.*\n+\s*19_ (?<Chapter_19>[^<]*)\n<(?<SAF>[^<]*)>.*\n+\s*20_ (?<Chapter_20>[^<]*)\n<(?<Rollback>[^<]*)>(?>.*\n)+\s*43_(?<Chapter_43>[^<]*)\n<(?<Impact>[^<]*)>" Local $sString = "" & @CRLF & _ "**************************************************************" & @CRLF & _ " - MANDATORY FOR ALL CHANGES -" & @CRLF & _ "**************************************************************" & @CRLF & _ "" & @CRLF & _ "1_ Motivation / Benefit / Reason for change " & @CRLF & _ "(Describe the Motivation, the benefit out of this change/ what will the change achieve/ what is the trigger/driver of this change)" & @CRLF & _ "<...> " & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "2_ What will happen if Change not performed" & @CRLF & _ "(Describe the risk of not implementing the change)" & @CRLF & _ "<...> " & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "3_ Change Scenario / detailed Implementation Steps" & @CRLF & _ "(Describe the change in a non-technical language/what will be changed)" & @CRLF & _ "<...>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "4_ Affected OpCo/customers" & @CRLF & _ "(Please use: All Customers/None/Name of customer)" & @CRLF & _ "<...>" & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ "5_ Affected Services" & @CRLF & _ "(List services which will be affected by the change: Data, IITC, SMS, Voice, Provisioning, M2M Portal, NB-IoT, B2C Portal, SOBE, API, Reporting, Billing, SMPP, Device Management, Customer Feature, WEB Service GUI, LBAS, C-IoT)" & @CRLF & _ "<...>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "6_ Describe the SERVICE IMPACT eg: any outages to Infrastructure hardware or temporary loss of service?" & @CRLF & _ "(Describe the EXPECTED SERVICE IMPACT, during change implementation, including duration: Service Affecting activity? Service Outage / Service Degradation /if there is no impact then mention why.)" & @CRLF & _ "<...>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "7_ Describe the RISKS during implementation/ what could go wrong? And add the worst case scenario." & @CRLF & _ "(What will the customer face if the something goes wrong during execution (Worst case scenario). If there is no risk then mention why.)" & @CRLF & _ "<...>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "8_ Pre-Implementation Tests/previous examples" & @CRLF & _ "(Please choose one of the following Test results evidences and provide the needed info, PLEASE COPY AND PAST YOUR CHOICE IN THE TRIANGLE BRACKETS:" & @CRLF & _ "a- Change has been performed before with same scenario successfully, CRQ examples: ..." & @CRLF & _ "b- Test document will be attached in work info [Y/N/NA]?: ..." & @CRLF & _ "c- Pilot testing was performed with users in Prod [Y/N/NA]?: ..." & @CRLF & _ "d- Test results can't be provided because: ....)" & @CRLF & _ "<...>" & @CRLF & _ "" & @CRLF & _ "9_ Test Scenario after change" & @CRLF & _ "(Brief Description regarding the list of activities which will be done when the change is completed)" & @CRLF & _ "<...>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "11_ Fallback Scenario" & @CRLF & _ "(Describe briefly what will be done in case of rollback)" & @CRLF & _ "<...>" & @CRLF & _ "" & @CRLF & _ "12_ Affected Configuration Items (CIs/Components as: CSDB/GDSP/IITC/GCSDB/GGSN)" & @CRLF & _ "<...>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "13_ Affected Data Centers " & @CRLF & _ "(Or Location: SPE1, SPE2, etc.)" & @CRLF & _ "<...>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "15_ Within maintenance window (Y/N, Why?)" & @CRLF & _ "(If the change is out of the agreed Maintenance Window, please specifiy why)" & @CRLF & _ "<...>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "19_ SAF [Y/N]" & @CRLF & _ "(Is the Activity Service Affecting [Y/N])" & @CRLF & _ "<...>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "20_ Rollback outage [Y/N]" & @CRLF & _ "(Is there a downtime during Rollback? If yes, mention the duration)" & @CRLF & _ "<...>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "22_ Fallback details (in UTC)" & @CRLF & _ "22a_ <Rollback Start: DD/MM/YYYY HH:MM>" & @CRLF & _ "" & @CRLF & _ "22b_ <Rollback End: DD/MM/YYYY HH:MM>"" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "40_ Change implementer (Group name, Operation Engineer Name & Email & contact number)" & @CRLF & _ "<...>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "41_ VBPS Validation/SLS MDS engineer for VBPS changes (Who validated the change?)" & @CRLF & _ "<...>" & @CRLF & _ "" & @CRLF & _ "42_ Capability Manager (Who reviewed the change for Level4)" & @CRLF & _ "<...>" & @CRLF & _ "" & @CRLF & _ "43_Anything impacted? [Y/N]" & @CRLF & _ "<...>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "--- End of required information --- *** Please Fill out *** " 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