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
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
  • Match everything enclosed
    (?:...)
  • Capture everything enclosed
    (...)
  • 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

/
/
gm

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 = "(?m)(^去机场$)|接送(机|服务)|送(到)?机(场|服务)" 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 & _ "接下总机。" & @CRLF & _ "嗯,有那个送机水好吧,这个房间没水的。" & @CRLF & _ "您好,八幺八房间帮我拿送机的话是上来行吗?" & @CRLF & _ "送机瓶水。" & @CRLF & _ "送机服务人工。" & @CRLF & _ "接送不。" & @CRLF & _ "没有叫他直接送到七二一房间就可以了。" & @CRLF & _ "接送车。" & @CRLF & _ "您好,接前台,然后送手机带过来。" & @CRLF & _ "没有,就是直接输入手机号完了那个来验证吗,验证一下就可以了事那意思不。" & @CRLF & _ "在给我接下机。" & @CRLF & _ "接总机就手机。" & @CRLF & _ "与接送的是浴巾两条浴巾,谢谢,能尽快吗?" & @CRLF & _ "请接总台总机总台。" & @CRLF & _ "哎,你好,可以帮我送机送冲个天吗?" & @CRLF & _ "送送机。" & @CRLF & _ "嗯,送机,即到给我。" & @CRLF & _ "嗯,连接送台。" & @CRLF & _ "转接总机。" & @CRLF & _ "送机瓶水。" & @CRLF & _ "我接总机那个前台。" & @CRLF & _ "接总机。" & @CRLF & _ "哦,我这个电视我要连接usb播放我手机的视频是怎么操作的,我这边不会弄,你可以叫人上来帮我弄吗?" & @CRLF & _ "酒店有送机服务吗?" & @CRLF & _ "嗯,接机前台。" & @CRLF & _ "我那个七五给送的矿泉水房间没打扫机送机行吗?" & @CRLF & _ "我,我在房间里就不行,送机瓶水。" & @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