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

Substitution

Processing...

Code Generator

Generated Code

#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox Local $sRegex = "(?m)^\[((?!(?:ti|ar|al|au|lr|length|by|offset|re|tool|ve|#|\d{1,2}):.+\]).*)\](\r?\n)(\[\d{1,2}:\d{1,2}\.\d{2,3}\])(.*)$" Local $sString = "[ti:Hey You]" & @CRLF & _ "[ar:Pink Floyd]" & @CRLF & _ "[al:The Wall (2011 Remaster)]" & @CRLF & _ "[au:Roger Waters]" & @CRLF & _ "[lr:Roger Waters]" & @CRLF & _ "[length:04:40]" & @CRLF & _ "[by: Casual Tea]" & @CRLF & _ "[offset:+300]" & @CRLF & _ "[re: Musicbee]" & @CRLF & _ "[tool: Mp3tag]" & @CRLF & _ "[ve: 1.2.3]" & @CRLF & _ "[#: A comment]" & @CRLF & _ "" & @CRLF & _ "[Acoustic Guitar Intro]" & @CRLF & _ "" & @CRLF & _ "[Verse 1: David Gilmour]" & @CRLF & _ "[00:35.485]Hey you" & @CRLF & _ "[00:38.184]Out there in the cold," & @CRLF & _ "[00:39.828]Getting lonely, getting old," & @CRLF & _ "[00:41.848]Can you feel me?" & @CRLF & _ "[00:46.137]Hey you" & @CRLF & _ "[00:48.659]Standing in the aisles" & @CRLF & _ "[00:50.250]With itchy feet and fading smiles," & @CRLF & _ "[00:52.611]Can you feel me?" & @CRLF & _ "[00:57.924]Hey, you, don't help them to bury the light" & @CRLF & _ "[01:08.393]Don't give in without a fight" & @CRLF & _ "[01:13.227]" & @CRLF & _ "[Verse 2: David Gilmour]" & @CRLF & _ "[01:20.282]Hey, you" & @CRLF & _ "[01:23.035]Out there on your own," & @CRLF & _ "[01:24.566]Sitting naked by the phone," & @CRLF & _ "[01:26.685]Would you touch me?" & @CRLF & _ "[01:30.958]Hey, you" & @CRLF & _ "[01:33.071]With your ear against the wall," & @CRLF & _ "[01:35.171]Waiting for someone to call out," & @CRLF & _ "[01:37.348]Would you touch me?" & @CRLF & _ "[01:42.711]Hey you, would you help me to carry the stone?" & @CRLF & _ "[01:52.884]Open your heart, I'm coming home" & @CRLF & _ "[01:58.076]" & @CRLF & _ "[Guitar Solo]" & @CRLF & _ "" & @CRLF & _ "[Bridge: Roger Waters]" & @CRLF & _ "[02:57.282]But it was only fantasy" & @CRLF & _ "[03:04.137]The wall was too high, as you can see" & @CRLF & _ "[03:11.617]No matter how he tried, he could not break free" & @CRLF & _ "[03:19.019]And the worms ate into his brain" & @CRLF & _ "[03:22.914]" & @CRLF & _ "[Verse 3: Roger Waters]" & @CRLF & _ "[03:54.974]Hey, you" & @CRLF & _ "[03:57.745]Out there on the road," & @CRLF & _ "[03:59.261]Always doing what you're told," & @CRLF & _ "[04:01.459]Can you help me?" & @CRLF & _ "[04:05.745]Hey, you" & @CRLF & _ "[04:08.135]Out there beyond the wall," & @CRLF & _ "[04:09.899]Breaking bottles in the hall," & @CRLF & _ "[04:12.108]Can you help me?" & @CRLF & _ "[04:17.481]Hey, you, don't tell me there's no hope at all" & @CRLF & _ "[04:27.360]Together we stand, divided we fall" & @CRLF & _ "" & @CRLF & _ "[Outro: Roger Waters]" & @CRLF & _ "[04:32.742](We fall)" & @CRLF & _ "[04:34.133](We fall)" & @CRLF & _ "[04:35.313](We fall)" & @CRLF & _ "[04:36.593](We fall)" & @CRLF & _ "[04:37.885](We fall)" & @CRLF & _ "[04:39.178](We fall)" & @CRLF & _ "[04:40.433]" Local $sSubst = "$3($1)$2$3$4" 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