Regular Expressions 101

Save & Share

  • Regex Version: ver. 3
  • 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
No Match

/
/
.style

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 = "(?.style)<!--block:(.*?)-->((?:(?:(?!<!--(.*?)-->).)|(?R))*?)<!--endblock-->" Local $sString = "<!DOCTYPE html><html><head><title>Crew Watch (Responses)</title>" & @CRLF & _ "<link href='/static/spreadsheets2/client/css/461985016-waffle_k_ltr.css' type='text/css' rel='stylesheet'><style type="text/css">" & @CRLF & _ " html { overflow: visible; }" & @CRLF & _ " #sheets-viewport { overflow: auto; }" & @CRLF & _ " #sheets-viewport.widget-viewport { overflow: hidden; }" & @CRLF & _ " .grid-container { overflow: visible; background: white;}" & @CRLF & _ " .grid-table-container { overflow: visible; }" & @CRLF & _ " #top-bar {" & @CRLF & _ " background: url("//ssl.gstatic.com/docs/spreadsheets/publishheader.png") repeat-x bottom;" & @CRLF & _ " margin: 0;" & @CRLF & _ " overflow: hidden;" & @CRLF & _ " }" & @CRLF & _ " #top-bar {" & @CRLF & _ " border-bottom: 1px solid #ccc;" & @CRLF & _ " padding: 6px 6px 0;" & @CRLF & _ " }" & @CRLF & _ " #doc-title { padding-bottom: 5px; }" & @CRLF & _ " #doc-title .name { font-size: 15px; }" & @CRLF & _ " #sheet-menu {" & @CRLF & _ " font-size: 13px;" & @CRLF & _ " margin: 6px 0 0;" & @CRLF & _ " padding: 0 0 5px;" & @CRLF & _ " }" & @CRLF & _ " #sheet-menu li {" & @CRLF & _ " display: inline;" & @CRLF & _ " list-style-type: none;" & @CRLF & _ " margin: 0;" & @CRLF & _ " padding: 5px 8px;" & @CRLF & _ " }" & @CRLF & _ " #sheet-menu li.active {" & @CRLF & _ " background-color: #fff;" & @CRLF & _ " font-weight: bold;" & @CRLF & _ " border: 1px solid #999;" & @CRLF & _ " }" & @CRLF & _ " #top-bar #sheet-menu li.active {" & @CRLF & _ " border-bottom: 0;" & @CRLF & _ " }" & @CRLF & _ " #sheet-menu a, #sheet-menu a:visited { color: #07c; }" & @CRLF & _ " .ritz .waffle .s0{text-align:left;color:#000000;background-color:#ffffff;font-family:arial,sans,sans-serif;font-size:10pt;vertical-align:bottom;white-space:nowrap;direction:ltr;padding:2px 3px 2px 3px;}.ritz .waffle .s1{text-align:right;color:#000000;background-color:#ffffff;font-family:arial,sans,sans-serif;font-size:10pt;vertical-align:bottom;white-space:nowrap;direction:ltr;padding:2px 3px 2px 3px;}</style><script type="text/javascript">" & @CRLF & _ " var activeSheetId;" & @CRLF & _ "" & @CRLF & _ " function switchToSheet(id) {" & @CRLF & _ " if (document.getElementById('sheet-menu')) {" & @CRLF & _ " document.getElementById('sheet-button-' + activeSheetId)" & @CRLF & _ " .className = '';" & @CRLF & _ " document.getElementById('sheet-button-' + id).className = 'active';" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " document.getElementById(activeSheetId).style.display = 'none';" & @CRLF & _ " document.getElementById(id).style.display = '';" & @CRLF & _ " activeSheetId = id;" & @CRLF & _ "" & @CRLF & _ " // posObjs() is defined in embeddedObjectJs (see EmbeddedObjectHtmlBuilder.java)" & @CRLF & _ " posObjs();" & @CRLF & _ " return false;" & @CRLF & _ " }" & @CRLF & _ " " & @CRLF & _ " function init() {" & @CRLF & _ " var optPageSwitcher;" & @CRLF & _ " " & @CRLF & _ " function resize() {" & @CRLF & _ " var optTopBar = document.getElementById('top-bar');" & @CRLF & _ " var adjustedHeight = window.innerHeight - (optTopBar ? optTopBar.offsetHeight : 0);" & @CRLF & _ " var adjustedWidth = window.innerWidth;" & @CRLF & _ " var sheetsViewport = document.getElementById('sheets-viewport');" & @CRLF & _ " sheetsViewport.style.width = (adjustedWidth + 'px');" & @CRLF & _ " sheetsViewport.style.height = (adjustedHeight + 'px');" & @CRLF & _ " if (optPageSwitcher) {" & @CRLF & _ " optPageSwitcher.resize(adjustedWidth, adjustedHeight);" & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ " resize();" & @CRLF & _ " window.onresize = resize;" & @CRLF & _ " }" & @CRLF & _ " </script></head><body onload=init()><div id="top-bar"><div id="doc-title"><span class="name">Crew Watch (Responses) : Form Responses 1</span></div></div><div id="sheets-viewport"><div id="1416730418" style="display:none;position:relative;" dir="ltr"><div class="ritz grid-container" dir="ltr"><table class="waffle" cellspacing="0" cellpadding="0"><thead><tr><th class="row-header freezebar-vertical-handle header-shim row-header-shim"></th><th id="1416730418C0" style="width:150px" class="header-shim"></th><th id="1416730418C1" style="width:150px" class="header-shim"></th><th id="1416730418C2" style="width:150px" class="header-shim"></th><th id="1416730418C3" style="width:150px" class="header-shim"></th><th id="1416730418C4" style="width:150px" class="header-shim"></th><th id="1416730418C5" style="width:150px" class="header-shim"></th><th id="1416730418C6" style="width:150px" class="header-shim"></th><th id="1416730418C7" style="width:150px" class="header-shim"></th><th id="1416730418C8" style="width:150px" class="header-shim"></th></tr></thead><tbody><tr style='height:21px;'><th id="1416730418R0" style="height: 21px;" class="row-headers-background row-header-shim"><div class="row-header-wrapper" style="line-height: 21px;">1</div></th><td class="s0">Timestamp</td><td class="s0">First Name</td><td class="s0">Middle Name</td><td class="s0">Last Name</td><td class="s0">Date of Birth</td><td class="s0">Street Address</td><td class="s0">City</td><td class="s0">State</td><td class="s0">Zip Code</td></tr><tr><th style="height:4px" class="freezebar-cell freezebar-horizontal-handle row-header-shim"></th><td class="freezebar-cell"></td><td class="freezebar-cell"></td><td class="freezebar-cell"></td><td class="freezebar-cell"></td><td class="freezebar-cell"></td><td class="freezebar-cell"></td><td class="freezebar-cell"></td><td class="freezebar-cell"></td><td class="freezebar-cell"></td></tr><tr style='height:21px;'><th id="1416730418R1" style="height: 21px;" class="row-headers-background row-header-shim"><div class="row-header-wrapper" style="line-height: 21px;">2</div></th><td class="s1" dir="ltr">3/26/2014 21:33:20</td><td class="s0" dir="ltr">John</td><td class="s0" dir="ltr">Collier</td><td class="s0" dir="ltr">Armstrong</td><td></td><td></td><td></td><td></td><td></td></tr><tr style='height:21px;'><th id="1416730418R2" style="height: 21px;" class="row-headers-background row-header-shim"><div class="row-header-wrapper" style="line-height: 21px;">3</div></th><td class="s1" dir="ltr">8/21/2014 0:56:02</td><td class="s0" dir="ltr">john</td><td class="s0" dir="ltr">collier</td><td class="s0" dir="ltr">armstrong</td><td class="s1" dir="ltr">1/10/1984</td><td class="s0" dir="ltr">4720 SW 21st St.</td><td class="s0" dir="ltr">Topeka</td><td></td><td class="s1" dir="ltr">66604</td></tr><tr style='height:21px;'><th id="1416730418R3" style="height: 21px;" class="row-headers-background row-header-shim"><div class="row-header-wrapper" style="line-height: 21px;">4</div></th><td class="s1" dir="ltr">9/11/2014 0:56:28</td><td class="s0" dir="ltr">Conner</td><td class="s0" dir="ltr">Goss</td><td class="s0" dir="ltr">Griffin</td><td class="s1" dir="ltr">8/31/1992</td><td></td><td class="s0" dir="ltr">Topeka</td><td></td><td></td></tr></tbody></table></div></div></div>" & @CRLF & _ "<script type='text/javascript'>" & @CRLF & _ "function posObj(sheet, id, row, col, x, y) {" & @CRLF & _ " var r = document.getElementById(sheet+'R'+row);" & @CRLF & _ " var c = document.getElementById(sheet+'C'+col);" & @CRLF & _ " if (r && c) {" & @CRLF & _ " var s = document.getElementById(id).style;" & @CRLF & _ " var t = y;" & @CRLF & _ " while (r) {" & @CRLF & _ " t += r.offsetTop;" & @CRLF & _ " r = r.offsetParent;" & @CRLF & _ " }" & @CRLF & _ " var l = x;" & @CRLF & _ " while (c) {" & @CRLF & _ " l += c.offsetLeft;" & @CRLF & _ " c = c.offsetParent;" & @CRLF & _ " }" & @CRLF & _ " s.left = l + 'px';" & @CRLF & _ " s.top = t + 'px';" & @CRLF & _ " s.display = 'block';" & @CRLF & _ " s.border = '1px solid #000000';" & @CRLF & _ " }" & @CRLF & _ "};" & @CRLF & _ "function posObjs() {" & @CRLF & _ "};" & @CRLF & _ "posObjs();</script>" & @CRLF & _ "<script type="text/javascript">activeSheetId = '1416730418'; switchToSheet('1416730418');</script></body></html>" 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