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 = "([0-9]{1,}:[0-9]{1,})" Local $sString = "...New developments in the ongoing controversy " & @CRLF & _ "0:05 surrounding Molecular Genetics. " & @CRLF & _ "0:07 Incoming reports now allege " & @CRLF & _ "0:08 MolGen’s involvement in illegal human cloning. " & @CRLF & _ "0:11 In a startling development, it appears " & @CRLF & _ "0:12 private security forces have taken over. " & @CRLF & _ "0:15 All this just two weeks after the controversial disappearance " & @CRLF & _ "0:18 of MolGen Chief Medical Officer Dr. Nora Phillips. " & @CRLF & _ "0:22 Anonymous sources saying there could be actual human clones inside. " & @CRLF & _ "0:44 Up and at ‘em, Five. " & @CRLF & _ "0:45 Let’s go. Get up! " & @CRLF & _ "0:49 Sir, FBI just breached the lobby. " & @CRLF & _ "0:51 It’s getting down to the wire. " & @CRLF & _ "0:53 Guess we better hurry then. " & @CRLF & _ "0:55 Get up, Five! " & @CRLF & _ "0:58 Why do you always have to make everything so hard. " & @CRLF & _ "1:01 Let's go. " & @CRLF & _ "1:05 Chrissakes, is that really necessary? " & @CRLF & _ "1:08 Keep moving. Keep moving. " & @CRLF & _ "1:14 All clear, let's go. " & @CRLF & _ "1:22 Let’s go! Move, move, move! " & @CRLF & _ "1:24 Goddamn abomination. " & @CRLF & _ "1:32 In position. Driver’s coming in. " & @CRLF & _ "1:39 Abomination. " & @CRLF & _ "1:41 Get the door, please. " & @CRLF & _ "1:47 Abomination. " & @CRLF & _ "1:49 From the latin word "abominari". " & @CRLF & _ "1:52 A thing that causes hatred or disgust. " & @CRLF & _ "1:54 Gentlemen, the specimen stays with me at all times. " & @CRLF & _ "1:58 Lead, follow, you offer support. " & @CRLF & _ "1:59 There is also an air unit that is active. " & @CRLF & _ "2:02 Right now we are surrounded by the FBI. " & @CRLF & _ "2:05 We will move out. We will move fast. " & @CRLF & _ "2:07 And if necessary we will push back. " & @CRLF & _ "2:10 The only thing that matters now " & @CRLF & _ "2:12 is getting the merchandise to the customer. " & @CRLF & _ "2:18 Let’s see if you’re worth the money. " & @CRLF & _ "2:20 You don’t need to baby-sit me. " & @CRLF & _ "2:22 I baby-sit everyone. " & @CRLF & _ "2:24 That’s kinda my thing. " & @CRLF & _ "2:38 What the — " & @CRLF & _ "3:04 They’re moving in. You got six on your tail. " & @CRLF & _ "3:06 Xavier, do me a favor. " & @CRLF & _ "3:07 Push ‘em back a little bit. " & @CRLF & _ "3:24 This is your world? " & @CRLF & _ "3:27 Have you never seen it before? " & @CRLF & _ "3:28 Drive the car. " & @CRLF & _ "3:29 Not with my eyes, no. " & @CRLF & _ "3:30 Five. Shut up. " & @CRLF & _ "3:32 But I know all about your world. " & @CRLF & _ "3:33 Really? " & @CRLF & _ "3:34 Do not communicate with the specimen... " & @CRLF & _ "3:37 - Alaska has a longer coastline... - Five... " & @CRLF & _ "3:39 - ...than all other 49 states combined. - Stop talking. " & @CRLF & _ "3:40 - If you want, I could tell you some — - Five, stop talking! " & @CRLF & _ "3:44 My name is Lilly. " & @CRLF & _ "3:47 Okay. " & @CRLF & _ "3:50 Please, those are mine. " & @CRLF & _ "3:51 I love her work. It’s great, isn’t it. " & @CRLF & _ "3:54 Such detail. That’s my favorite. " & @CRLF & _ "3:57 She's really something else. " & @CRLF & _ "4:17 Okay... " & @CRLF & _ "4:19 Cut him off! " & @CRLF & _ "4:21 Stop the car. " & @CRLF & _ "4:26 Three seconds. " & @CRLF & _ "4:28 Two. " & @CRLF & _ "4:30 One. " & @CRLF & _ "4:35 Get out. " & @CRLF & _ "4:37 Okay. " & @CRLF & _ "4:38 Do you have any idea what you just did? " & @CRLF & _ "4:48 I might be a little rusty right now, " & @CRLF & _ "4:50 but I’ve been doing this for a long time. " & @CRLF & _ "4:52 I’m very good at it. " & @CRLF & _ "4:53 That only means your chances " & @CRLF & _ "4:54 of failure increase with each outing. " & @CRLF & _ "4:57 Statistically speaking. " & @CRLF & _ "4:59 The odds will be what the odds will be. " & @CRLF & _ "5:01 Get out. " & @CRLF & _ "5:03 You’re dead, mystery man. " & @CRLF & _ "5:05 You’re dead. " & @CRLF & _ "5:08 You mind? " & @CRLF & _ "5:18 Air unit one in pursuit. " & @CRLF & _ "5:20 No, no, no, no, the driver’s mine! " & @CRLF & _ "5:22 Buckle up... " & @CRLF & _ "5:36 Let’s go, let’s go! " & @CRLF & _ "5:47 Lower! Lower! " & @CRLF & _ "5:53 Lower! " & @CRLF & _ "5:54 What part of “lower” don’t you understand?! " & @CRLF & _ "7:58 Mercy. " & @CRLF & _ "7:59 From Old French, merced. " & @CRLF & _ "8:02 Kindness. Grace. Pity. " & @CRLF & _ "8:30 Put your hands up! " & @CRLF & _ "8:31 On your knees! " & @CRLF & _ "9:00 You okay? " & @CRLF & _ "9:05 Dr. Phillips. " & @CRLF & _ "9:08 Yes. " & @CRLF & _ "9:10 She made Tulip and Rose and Daffodil... " & @CRLF & _ "9:14 and me. " & @CRLF & _ "9:17 They’re all gone now. " & @CRLF & _ "9:22 Look. " & @CRLF & _ "9:39 Hello, Lilly. " & @CRLF & _ "9:56 Keep it. " & @CRLF & _ "9:57 Thank you." & @CRLF & _ "" 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