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

/
/

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 = "[(bitrate:\ )] (\d*) [(kb\/s)]" Local $sString = "ffmpeg version git-2012-01-25-247d30a Copyright (c) 2000-2012 the FFmpeg developers" & @CRLF & _ " built on Jan 25 2012 16:56:18 with gcc 4.6.2" & @CRLF & _ " configuration: --extra-cflags=-I../static/include --extra-ldflags='-L../static/lib -static' --enable-gpl --enable-version3 --enable-static --disable-shared --disable-debug --enable-runtime-cpudetect --enable-x11grab --enable-libmp3lame --enable-libx264 --enable-libspeex --enable-libvorbis --enable-libvpx --enable-libfreetype --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libxavs --enable-libtheora --enable-libvo-aacenc --enable-libvo-amrwbenc --disable-ffserver" & @CRLF & _ " libavutil 51. 34.101 / 51. 34.101" & @CRLF & _ " libavcodec 53. 59.100 / 53. 59.100" & @CRLF & _ " libavformat 53. 30.100 / 53. 30.100" & @CRLF & _ " libavdevice 53. 4.100 / 53. 4.100" & @CRLF & _ " libavfilter 2. 60.100 / 2. 60.100" & @CRLF & _ " libswscale 2. 1.100 / 2. 1.100" & @CRLF & _ " libswresample 0. 6.100 / 0. 6.100" & @CRLF & _ " libpostproc 52. 0.100 / 52. 0.100" & @CRLF & _ "Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '3825402d75f04cadad96fa9f3af62c82.mp4':" & @CRLF & _ " Metadata:" & @CRLF & _ " major_brand : mp42" & @CRLF & _ " minor_version : 0" & @CRLF & _ " compatible_brands: mp41isom" & @CRLF & _ " creation_time : 2016-09-30 16:14:06" & @CRLF & _ " Duration: 00:00:15.04, start: 0.000000, bitrate: 1609 kb/s" & @CRLF & _ " Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1152x720 [SAR 1:1 DAR 8:5], 1611 kb/s, 30.30 fps, 30.30 tbr, 30k tbn, 60 tbc" & @CRLF & _ " Metadata:" & @CRLF & _ " creation_time : 2016-09-30 16:14:06" & @CRLF & _ " handler_name : VideoHandler" & @CRLF & _ "At least one output file must be specified" & @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