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

~
~
x

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 = "(?x){@ (?<cond>\w+) - (?<stat>\w+(?:%\w+)*) (?: : (?<sub>\w+))? \|" & @CRLF & _ "" & @CRLF & _ "# a "THEN" part that doesn't have a nested conditional statement" & @CRLF & _ "(?<then>[^{|@]*+ (?: {(?!@) [^{|@]* | @(?!}) [^{|@]* )*+ )" & @CRLF & _ "" & @CRLF & _ "# optional "ELSE" part (the content is similar to the "THEN" part)" & @CRLF & _ "(?: \| (?<else> \g<then> ) )? (*SKIP) @}" Local $sString = "{@if-is_not_logged_homepage|" & @CRLF & _ "<header id="header_home">" & @CRLF & _ " <div class="in">" & @CRLF & _ " <div class="top">" & @CRLF & _ " <h1 class="logo"><a href="/"><img src="/img/logo-home.png" alt=""></a></h1>" & @CRLF & _ " <div class="login_outer_wrapper">" & @CRLF & _ " <button id="login"><div class="a"><i class="stripe"><i></i></i>Log in</div></button>" & @CRLF & _ " <div id="login_wrapper">" & @CRLF & _ " <form method="post" action="{^login^}" id="form_login_global">" & @CRLF & _ " <div class="form_field no_description">" & @CRLF & _ " <label>{!auth:login_email!}</label>" & @CRLF & _ " <div class="input"><input type="text" name="form[login]"></div>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="form_field no_description password">" & @CRLF & _ " <label>{!auth:password!}</label>" & @CRLF & _ " <div class="input"><input type="password" name="form[password]"></div>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="remember">" & @CRLF & _ " <input type="checkbox" name="remember" id="remember_me_check" checked>" & @CRLF & _ " <label for="remember_me_check"><i class="fa fa-check" aria-hidden="true"></i>Remember</label>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="submit_box">" & @CRLF & _ " <button class="btn btn_check">Log in</button>" & @CRLF & _ " </div>" & @CRLF & _ " </form>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="content clr">" & @CRLF & _ " <div class="main_menu">" & @CRLF & _ " <a href="">" & @CRLF & _ " <i class="ico a"><i class="fa fa-lightbulb-o" aria-hidden="true"></i></i>" & @CRLF & _ " <span>Idea</span>" & @CRLF & _ " <div>&nbsp;</div>" & @CRLF & _ " </a>" & @CRLF & _ " <a href="">" & @CRLF & _ " <i class="ico b"><i class="fa fa-user" aria-hidden="true"></i></i>" & @CRLF & _ " <span>FFa</span>" & @CRLF & _ " </a>" & @CRLF & _ " <a href="">" & @CRLF & _ " <i class="ico c"><i class="fa fa-briefcase" aria-hidden="true"></i></i>" & @CRLF & _ " <span>Buss</span>" & @CRLF & _ " </a>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="text_wrapper">" & @CRLF & _ "" & @CRLF & _ " <div>" & @CRLF & _ " <div class="register_wrapper">" & @CRLF & _ " <a id="main_register" class="btn register">Załóż konto</a>" & @CRLF & _ " <form method="post" action="{^login^}" id="form_register_home">" & @CRLF & _ " <div class="form_field no_description">" & @CRLF & _ " <label>{!auth:email!}</label>" & @CRLF & _ " <div class="input"><input type="text" name="form2[email]"></div>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="form_field no_description password">" & @CRLF & _ " <label>{!auth:password!}</label>" & @CRLF & _ " <div class="input tooltip"><input type="password" name="form2[password]"><i class="fa fa-info-circle tooltip_open" aria-hidden="true" title="{!auth:password_format!}"></i></div>" & @CRLF & _ "" & @CRLF & _ " </div>" & @CRLF & _ " <div class="form_field terms no_description">" & @CRLF & _ " <div class="input">" & @CRLF & _ " <input type="checkbox" name="form2[terms]" id="terms_check">" & @CRLF & _ " <label for="terms_check"><i class="fa fa-check" aria-hidden="true"></i>Agree</label>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="form_field no_description">" & @CRLF & _ " <div class="input captcha_wrapper">" & @CRLF & _ " <div class="g-recaptcha" data-sitekey="{%captcha_public_key%}"></div>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="submit_box">" & @CRLF & _ " <button class="btn btn_check">{!auth:register_btn!}</button>" & @CRLF & _ " </div>" & @CRLF & _ " </form>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ "</header>" & @CRLF & _ "| babubibo" & @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