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

/
/
g

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 = "[幹乾淦贛干肏操糙去塞賽]?[林賃吝拎恁你他她它祂牠](娘|媽|老師|妹|祖?(嬤|媽|罵))(的|樂|叻|垃|勒|咧|([基唧雞機激][掰歪]))?|([基唧雞機激][掰歪])" Local $sString = "幹" & @CRLF & _ "幹他媽的" & @CRLF & _ "幹你娘" & @CRLF & _ "乾" & @CRLF & _ "乾林老師" & @CRLF & _ "靠" & @CRLF & _ "靠北" & @CRLF & _ "靠杯" & @CRLF & _ "靠背" & @CRLF & _ "靠盃" & @CRLF & _ "靠腰" & @CRLF & _ "靠夭" & @CRLF & _ "哭夭" & @CRLF & _ "" & @CRLF & _ "去你的" & @CRLF & _ "去你媽的" & @CRLF & _ "" & @CRLF & _ "林北" & @CRLF & _ "恁北" & @CRLF & _ "恁娘" & @CRLF & _ "恁祖媽" & @CRLF & _ "機掰" & @CRLF & _ "賤" & @CRLF & _ "俗辣" & @CRLF & _ "他媽的" & @CRLF & _ "覽趴" & @CRLF & _ "懶趴" & @CRLF & _ "北爛" & @CRLF & _ "盧小" & @CRLF & _ "魯洨" & @CRLF & _ "色龜" & @CRLF & _ "肚爛" & @CRLF & _ "屌" & @CRLF & _ "啥小" & @CRLF & _ "三小" & @CRLF & _ "操" & @CRLF & _ "屁" & @CRLF & _ "唬爛" & @CRLF & _ "龜公" & @CRLF & _ "他奶奶的" & @CRLF & _ "犯賤" & @CRLF & _ "機車" & @CRLF & _ "智缺" & @CRLF & _ "你娘卡好" & @CRLF & _ "林老師" & @CRLF & _ "破麻" & @CRLF & _ "賽" & @CRLF & _ "操卒仔" & @CRLF & _ "操機歪" & @CRLF & _ "糙機掰" & @CRLF & _ "無懶趴" & @CRLF & _ "卡小" & @CRLF & _ "吃小" & @CRLF & _ "死魚眼" & @CRLF & _ "炭甲查某" & @CRLF & _ "糙你妹" & @CRLF & _ "GGININ" & @CRLF & _ "GG IN IN" & @CRLF & _ "GG IN IN DER" & @CRLF & _ "可惡 想揉" & @CRLF & _ "想揉" & @CRLF & _ "ㄈㄈ尺" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "英文原生:" & @CRLF & _ "CCR" & @CRLF & _ "Fuck off" & @CRLF & _ "Fuck" & @CRLF & _ "mother fucker" & @CRLF & _ "You SOB" & @CRLF & _ "son of a bitch" & @CRLF & _ "Go to hell" & @CRLF & _ "Shit-head" & @CRLF & _ "Asshole" & @CRLF & _ "You beast" & @CRLF & _ "Shit" & @CRLF & _ "fart" & @CRLF & _ "Idiot" & @CRLF & _ "damn it " & @CRLF & _ "God damn" & @CRLF & _ "God damn it" & @CRLF & _ "hypocrite" & @CRLF & _ "ass hole" & @CRLF & _ "ass licker" & @CRLF & _ "bitch " & @CRLF & _ "phycho" & @CRLF & _ "bastard" & @CRLF & _ "Whore" & @CRLF & _ "Slut" & @CRLF & _ "Shit-head" & @CRLF & _ "" Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH) Local $aFullArray[0] For $i = 0 To UBound($aArray) -1 _ArrayConcatenate($aFullArray, $aArray[$i]) Next $aArray = $aFullArray ; 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