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

/
/

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 = "(-- iOS 8\.2 --)\G|.(?:iPhone 4s.\((.*?)\))" Local $sString = "== Device Types ==" & @CRLF & _ "iPhone 4s (com.apple.CoreSimulator.SimDeviceType.iPhone-4s)" & @CRLF & _ "iPhone 5 (com.apple.CoreSimulator.SimDeviceType.iPhone-5)" & @CRLF & _ "iPhone 5s (com.apple.CoreSimulator.SimDeviceType.iPhone-5s)" & @CRLF & _ "iPhone 6 Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus)" & @CRLF & _ "iPhone 6 (com.apple.CoreSimulator.SimDeviceType.iPhone-6)" & @CRLF & _ "iPad 2 (com.apple.CoreSimulator.SimDeviceType.iPad-2)" & @CRLF & _ "iPad Retina (com.apple.CoreSimulator.SimDeviceType.iPad-Retina)" & @CRLF & _ "iPad Air (com.apple.CoreSimulator.SimDeviceType.iPad-Air)" & @CRLF & _ "Resizable iPhone (com.apple.CoreSimulator.SimDeviceType.Resizable-iPhone)" & @CRLF & _ "Resizable iPad (com.apple.CoreSimulator.SimDeviceType.Resizable-iPad)" & @CRLF & _ "== Runtimes ==" & @CRLF & _ "iOS 8.1 (8.1 - 12B411) (com.apple.CoreSimulator.SimRuntime.iOS-8-1)" & @CRLF & _ "iOS 8.2 (8.2 - 12D508) (com.apple.CoreSimulator.SimRuntime.iOS-8-2)" & @CRLF & _ "== Devices ==" & @CRLF & _ "-- iOS 8.1 --" & @CRLF & _ " iPhone 4s (F05C1130-5F17-483C-8545-41DB60BD6729) (Shutdown)" & @CRLF & _ "-- iOS 8.2 --" & @CRLF & _ " iPhone 4s (F05C1130-5F17-483C-8545-41DB60BD6729) (Shutdown)" & @CRLF & _ " iPhone 5 (6A9974F3-4C46-4583-9D74-A1083E76CCB9) (Shutdown)" & @CRLF & _ " iPhone 5s (89547F56-69D0-4696-98F5-9C4AF58BEC08) (Shutdown)" & @CRLF & _ " iPhone 6 Plus (AD19FA1E-4091-44D7-900E-E9BDF6E22460) (Shutdown)" & @CRLF & _ " iPhone 6 (6D639171-D599-43E9-BFCF-CD2765CE4DEE) (Booted)" & @CRLF & _ " iPad 2 (C8A1DF07-27D9-467F-BBCC-C76695C81BD0) (Shutdown)" & @CRLF & _ " iPad Retina (3ED6ED7E-D173-4C50-88EB-AB2F1CCA30D0) (Shutdown)" & @CRLF & _ " iPad Air (9FF89D26-305F-4BBF-8BC6-90BB2AE4C424) (Shutdown)" & @CRLF & _ " Resizable iPhone (C4BC5922-316C-4176-96FE-8FE2B066C1FD) (Shutdown)" & @CRLF & _ " Resizable iPad (DCF07107-4FD4-4B77-A531-0B652F6C1C61) (Shutdown)" & @CRLF & _ "-- Unavailable: com.apple.CoreSimulator.SimRuntime.iOS-8-3 --" & @CRLF & _ " iPhone 4s (F88A4DF6-3B81-445D-A296-73CC69CE7FE6) (Shutdown) (unavailable, runtime profile not found)" & @CRLF & _ " iPhone 5 (ED535FC5-34CE-43B4-ABCA-C57093F7D8FF) (Shutdown) (unavailable, runtime profile not found)" & @CRLF & _ " iPhone 5s (7CFE4925-328E-483E-B137-996520446291) (Shutdown) (unavailable, runtime profile not found)" & @CRLF & _ " iPhone 6 Plus (1BAD21C1-33B8-49A1-90F1-6C9C4FDDDE4B) (Shutdown) (unavailable, runtime profile not found)" & @CRLF & _ " iPhone 6 (3EDA5D17-001B-49CD-83A6-7E1A3926CB28) (Shutdown) (unavailable, runtime profile not found)" & @CRLF & _ " iPad 2 (EA7BBF7B-CFA1-49A6-A84D-471F31E832B8) (Shutdown) (unavailable, runtime profile not found)" & @CRLF & _ " iPad Retina (52B69DBB-352A-49C9-9B56-8EEB463DD023) (Shutdown) (unavailable, runtime profile not found)" & @CRLF & _ " iPad Air (CF60978F-52EF-4E12-8B63-02BEA30D1702) (Shutdown) (unavailable, runtime profile not found)" & @CRLF & _ " Resizable iPhone (903870E3-FF55-48BB-953F-26CCBAFE5E45) (Shutdown) (unavailable, runtime profile not found)" & @CRLF & _ " Resizable iPad (C447F468-2FCE-4731-8CAA-86922F8002CC) (Shutdown) (unavailable, runtime profile not found)" Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYFULLMATCH) ; 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