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

/
/
gm

Test String

Code Generator

Generated Code

// include the latest version of the regex crate in your Cargo.toml extern crate regex; use regex::Regex; fn main() { let regex = Regex::new(r"(?m)(^去机场$)|接送(机|服务)|送(到)?机(场|服务)").unwrap(); let string = "嗯,您一般怎么去机场。 怎么去机场? 想不通八十中机场吗下还是一月画画,数学电视能想课程要宝宝机构。 再给我送机场。 去机场叫的士。 帮我现在一次在楼下去机场。 额,我说我这会退票,呃退房要去机场,如果需要查房,你那服务员现在上来啊。 不用了,不用了,就是现金早餐,我就在到机场坐飞机来好吗? 啊,你好,我想咨询一下,就是那个,嗯,我我老是是同一间房间,然后我老是明天是赶飞机,我想我明天可以帮她办一下退房吗? 嗯,去机场怎么走啊?怎么酒店? 你说的飞机电话。 温州机场吗?回家音乐。 给我送到机场。 去机场 机场? 去机场。 我们那个飞机,谢谢啊。 就是把床单被套整套换了最后在在要西城地板机场。 麻烦机场总台。 去机场要多久? 来不了也没有车,方便过去不稳,同样就座是不是不免不是没有了,不再那边那里医院的那里吧,那一个什么,什么阴阳桃林机场在这个就是。 喂,那个我咱们这有机场大巴吗? 您好,麻烦帮三零二多送一床被子。这里飞机太薄了。 飞机? 嗯,空调丰富开到机场。 去机场要多久? 机场台下。 啊,八零八房间马上给送机瓶水了。 呃,送机矿泉水,谢谢。 投影仪,可不可以连接手机。 请给我接送服务。不。 再给我送机场。 接送服务。 给我送给我接送餐服务。 帮我接机不。 麻烦送机桶水吧。 转接转接送餐电话。 你好,是幺零零六送机瓶水吧。 请接机。 不要送洗衣服有送机服务吗? 你好,能接送明天吗? 嗯,接送机。 我送机没看出水吗? 体重称九幺六房接送一下。 你们有没有接送机啊。 接送。 有人接给我送两个手机就行了。 给我安排的接送机。 请转接送餐服务的电话? 为送机瓶水。 那个接下总机。 我需要那个帮我送机瓶水。 嗯,转接送餐服务。 接下总机。 嗯,有那个送机水好吧,这个房间没水的。 您好,八幺八房间帮我拿送机的话是上来行吗? 送机瓶水。 送机服务人工。 接送不。 没有叫他直接送到七二一房间就可以了。 接送车。 您好,接前台,然后送手机带过来。 没有,就是直接输入手机号完了那个来验证吗,验证一下就可以了事那意思不。 在给我接下机。 接总机就手机。 与接送的是浴巾两条浴巾,谢谢,能尽快吗? 请接总台总机总台。 哎,你好,可以帮我送机送冲个天吗? 送送机。 嗯,送机,即到给我。 嗯,连接送台。 转接总机。 送机瓶水。 我接总机那个前台。 接总机。 哦,我这个电视我要连接usb播放我手机的视频是怎么操作的,我这边不会弄,你可以叫人上来帮我弄吗? 酒店有送机服务吗? 嗯,接机前台。 我那个七五给送的矿泉水房间没打扫机送机行吗? 我,我在房间里就不行,送机瓶水。 嗯,我需要一副一次性剃须刀,你们这有配吗?有的话就帮我送上来,直接送房里。"; // result will be an iterator over tuples containing the start and end indices for each match in the string let result = regex.captures_iter(string); for mat in result { println!("{:?}", mat); } }

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 Rust, please visit: https://docs.rs/regex/latest/regex/