Regular Expressions 101

Save & Share

  • Regex Version: ver. 1
  • 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)[\s]+<\/coordinates>[\s\S]+?<coordinates>[\s]+" Local $sString = "<?xml version="1.0" encoding="UTF-8"?>" & @CRLF & _ "<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">" & @CRLF & _ "<Document>" & @CRLF & _ " <name>Example.kml</name>" & @CRLF & _ " <Style id="s_ylw-pushpin_hl">" & @CRLF & _ " <IconStyle>" & @CRLF & _ " <scale>1.3</scale>" & @CRLF & _ " <Icon>" & @CRLF & _ " <href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>" & @CRLF & _ " </Icon>" & @CRLF & _ " <hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>" & @CRLF & _ " </IconStyle>" & @CRLF & _ " <LineStyle>" & @CRLF & _ " <color>ffff00ff</color>" & @CRLF & _ " <width>4</width>" & @CRLF & _ " </LineStyle>" & @CRLF & _ " </Style>" & @CRLF & _ " <StyleMap id="m_ylw-pushpin">" & @CRLF & _ " <Pair>" & @CRLF & _ " <key>normal</key>" & @CRLF & _ " <styleUrl>#s_ylw-pushpin</styleUrl>" & @CRLF & _ " </Pair>" & @CRLF & _ " <Pair>" & @CRLF & _ " <key>highlight</key>" & @CRLF & _ " <styleUrl>#s_ylw-pushpin_hl</styleUrl>" & @CRLF & _ " </Pair>" & @CRLF & _ " </StyleMap>" & @CRLF & _ " <Style id="s_ylw-pushpin">" & @CRLF & _ " <IconStyle>" & @CRLF & _ " <scale>1.1</scale>" & @CRLF & _ " <Icon>" & @CRLF & _ " <href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>" & @CRLF & _ " </Icon>" & @CRLF & _ " <hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>" & @CRLF & _ " </IconStyle>" & @CRLF & _ " <LineStyle>" & @CRLF & _ " <color>ffff00ff</color>" & @CRLF & _ " <width>4</width>" & @CRLF & _ " </LineStyle>" & @CRLF & _ " </Style>" & @CRLF & _ " <Folder>" & @CRLF & _ " <name>Example</name>" & @CRLF & _ " <open>1</open>" & @CRLF & _ " <Placemark>" & @CRLF & _ " <name>Untitled Path</name>" & @CRLF & _ " <styleUrl>#m_ylw-pushpin</styleUrl>" & @CRLF & _ " <LineString>" & @CRLF & _ " <tessellate>1</tessellate>" & @CRLF & _ " <coordinates>" & @CRLF & _ " 1.010794386877401,44.51240983736842,0 0.6286744887979312,47.46969863211312,0 4.198175193521713,47.66272708685459,0 4.47650525274385,45.32855385904715,0 " & @CRLF & _ " </coordinates>" & @CRLF & _ " </LineString>" & @CRLF & _ " </Placemark>" & @CRLF & _ " <Placemark>" & @CRLF & _ " <name>Untitled Path</name>" & @CRLF & _ " <styleUrl>#m_ylw-pushpin</styleUrl>" & @CRLF & _ " <LineString>" & @CRLF & _ " <tessellate>1</tessellate>" & @CRLF & _ " <coordinates>" & @CRLF & _ " 8.904276108011693,51.53463622874661,0 9.185337211508118,53.24757135457648,0 12.82197202867711,52.85957127892767,0 9.326760498064647,50.5694391186729,0 " & @CRLF & _ " </coordinates>" & @CRLF & _ " </LineString>" & @CRLF & _ " </Placemark>" & @CRLF & _ " <Placemark>" & @CRLF & _ " <name>Untitled Path</name>" & @CRLF & _ " <styleUrl>#m_ylw-pushpin</styleUrl>" & @CRLF & _ " <LineString>" & @CRLF & _ " <tessellate>1</tessellate>" & @CRLF & _ " <coordinates>" & @CRLF & _ " -0.8457721243506866,53.25357789001806,0 -2.495344342945436,52.51894778278026,0 -1.832838168564855,51.68947925151446,0 -0.004852378987588724,51.90053296811562,0 " & @CRLF & _ " </coordinates>" & @CRLF & _ " </LineString>" & @CRLF & _ " </Placemark>" & @CRLF & _ " </Folder>" & @CRLF & _ "</Document>" & @CRLF & _ "</kml>" & @CRLF & _ "" Local $sSubst = " " 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