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
No Match

r"
"
s

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 = "(?s)<script>.*?(var.*?;).*?</script>" Local $sString = "<script><!--" & @CRLF & _ "var STATIC_BASE = '//cdn1.editmysite.com/';" & @CRLF & _ "var STYLE_PREFIX = 'wsite';" & @CRLF & _ "//-->" & @CRLF & _ "</script>" & @CRLF & _ "<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>" & @CRLF & _ "<script src='//cdn2.editmysite.com/js/site/main.js?buildTime=1400799662'></script>" & @CRLF & _ "<script>_W.relinquish && _W.relinquish()</script>" & @CRLF & _ "<script type='text/javascript'><!--" & @CRLF & _ "(function(jQuery){" & @CRLF & _ "function initFlyouts(){initPublishedFlyoutMenus([{"id":"408147401478827578","title":"HOME","url":"index.html","target":""},{"id":"852985120278826572","title":"GET A DOMAIN","url":"get-a-domain.html","target":""},{"id":"745935904556716097","title":"SERVICES","url":"services.html","target":""},{"id":"505441827833699923","title":"MY ACCOUNT","url":"my-account.html","target":""},{"id":"464549931862712377","title":"ABOUT US","url":"about-us.html","target":""}],"408147401478827578","<li><a href='#'>{{title}}<\/a><\/li>",'active',false)}" & @CRLF & _ "if (jQuery) {" & @CRLF & _ "if (jQuery.browser.msie && !window.flyoutMenusRefreshable) window.onload = initFlyouts;" & @CRLF & _ "else jQuery(initFlyouts);" & @CRLF & _ "}else{" & @CRLF & _ "if (Prototype.Browser.IE) window.onload = initFlyouts;" & @CRLF & _ "else document.observe('dom:loaded', initFlyouts);" & @CRLF & _ "}" & @CRLF & _ "})(window._W && _W.jQuery)" & @CRLF & _ "//-->" & @CRLF & _ "</script>" & @CRLF & _ "</head>" & @CRLF & _ "<body class=' wsite-theme-light wsite-page-index'>" & @CRLF & _ "<div id="fb-root"></div>" & @CRLF & _ "<script>(function(d, s, id) {" & @CRLF & _ " var js, fjs = d.getElementsByTagName(s)[0];" & @CRLF & _ " if (d.getElementById(id)) return;" & @CRLF & _ " js = d.createElement(s); js.id = id;" & @CRLF & _ " js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=109188665774734&version=v2.0";" & @CRLF & _ " fjs.parentNode.insertBefore(js, fjs);" & @CRLF & _ "}(document, 'script', 'facebook-jssdk'));</script>" & @CRLF & _ "<div id="nav-fixed">" & @CRLF & _ " <div id="nav-body">" & @CRLF & _ " <span style="visibility:hidden">Pwns.me</span> <ul class='wsite-menu-default'><li id='active'><a href='/'>HOME</a></li><li id='pg852985120278826572'><a href='/get-a-domain.html'>GET A DOMAIN</a></li><li id='pg745935904556716097'><a href='/services.html'>SERVICES</a></li><li id='pg505441827833699923'><a href='/my-account.html'>MY ACCOUNT</a></li><li id='pg464549931862712377'><a href='/about-us.html'>ABOUT US</a></li></ul>" & @CRLF & _ " </div>" & @CRLF & _ "</div>" & @CRLF & _ "<div id="pwns-logo">" & @CRLF & _ "<span style="display:hidden;" david="gay"></span>" & @CRLF & _ "</div>" & @CRLF & _ "<div id="content-body">" & @CRLF & _ "<div id="titleImg">" & @CRLF & _ "<img src="/files/theme/middlef.png">" & @CRLF & _ "</div>" & @CRLF & _ "<div id="que">" & @CRLF & _ "<ul>" & @CRLF & _ "<li><a href="about-us.html">QUE?</a> </li>" & @CRLF & _ "<li><a href="get-a-domain.html">SEEMS LEGIT</a> </li>" & @CRLF & _ "</ul>" & @CRLF & _ "</div>" & @CRLF & _ "" & @CRLF & _ "</div>" & @CRLF & _ "" & @CRLF & _ "<div id="social">" & @CRLF & _ "<div class="fb-like" data-href="http://pwns.me" data-layout="button" data-action="like" data-show-faces="false" data-share="false"></div><br><br>" & @CRLF & _ "<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://pwns.me" data-text="Pwns.me - Awesome domains" data-count="none" data-hashtags="pwns">Tweet</a>" & @CRLF & _ "<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>" & @CRLF & _ "</div>" & @CRLF & _ "" & @CRLF & _ "<div id="myFooter"> Brought to you by Awesomness. </div>" & @CRLF & _ "<div style="display:none;">" & @CRLF & _ "<div><div class='wsite-elements wsite-footer'>" & @CRLF & _ "<div><div class="wsite-multicol"><div class='wsite-multicol-table-wrap' style='margin:0 -15px'>" & @CRLF & _ "<table class='wsite-multicol-table'>" & @CRLF & _ "<tbody class='wsite-multicol-tbody'>" & @CRLF & _ "<tr class='wsite-multicol-tr'>" & @CRLF & _ "<td class='wsite-multicol-col' style='width:50%;padding:0 15px'></td>" & @CRLF & _ "<td class='wsite-multicol-col' style='width:50%;padding:0 15px'></td>" & @CRLF & _ "</tr>" & @CRLF & _ "</tbody>" & @CRLF & _ "</table>" & @CRLF & _ "</div></div></div>" & @CRLF & _ "" & @CRLF & _ "<div class="weebly-footer" style="text-align:right;"><div style="height:10px;overflow:hidden"></div>" & @CRLF & _ "Proudly powered by <a href="http://www.weebly.com/?utm_source=internal&utm_medium=footer&utm_campaign=2" href="_blank">Weebly</a>" & @CRLF & _ "<div style="height:10px;overflow:hidden"></div></div></div>" & @CRLF & _ "<script type='text/javascript'>" & @CRLF & _ "<!--" & @CRLF & _ "" & @CRLF & _ "if (document.cookie.match(/(^|;)\s*is_mobile=1/)) {" & @CRLF & _ " var windowHref = window.location.href || '';" & @CRLF & _ " if (windowHref.indexOf('?') > -1) {" & @CRLF & _ " windowHref += '&';" & @CRLF & _ " } else {" & @CRLF & _ " windowHref += '?';" & @CRLF & _ " }" & @CRLF & _ " document.write(" & @CRLF & _ " "&nbsp;&nbsp;&nbsp;&nbsp;" +" & @CRLF & _ " "<a class='wsite-view-link-mobile' href='" + windowHref + "view=mobile'>Mobile Site</a>"" & @CRLF & _ " );" & @CRLF & _ "}" & @CRLF & _ "" 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