Regular Expressions 101

Save & Manage Regex

  • Current Version: 1
  • Save & Share
  • Community Library

Flavor

  • PCRE2 (PHP)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java
  • .NET 7.0 (C#)
  • Rust
  • PCRE (Legacy)
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests
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
  • 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
Processing...

Test String

Code Generator

Generated Code

$re = '/职业学院|技工学院|招生代表|短期项目|背景提升|美国新闻|大专留学|专科留学|工薪家庭|在地服务|澳洲八大|卧龙岗大学|庆应义塾|浦项理工|浦项科技|成均馆|先修课程|桥梁课程|多点问|多点君|专升本|专升硕|三校生|双录取|微留学|低成本|永居|\bH1B\b|\bEB5\b|\bIB课程|\bQS排名|英国G5\b|大学(?!校|院|府|习|术|历|制|士|位|期|年|系|生|长|姐|科|问|会|员|费|派|说)|小学(?!校|院|府|习|术|历|制|士|位|期|年|系|生|长|姐|科|问|会|员|费|派|说)|高中(?!国|华|央|共|心|兴|校|尉|士|卫|型|层|产|秋)|初中(?!国|华|央|共|心|兴|校|尉|士|卫|型|层|产|秋)|夏校(?!正|对)|(?<!成|败|业|佳|功)绩点|(?<!提|及|趁|尽|一|赶)早行动|(?<!提|及|趁|尽|一|赶)早决定|(?<!慰|考|顾|责)问多点|(?<!高|初)中学(?!校|院|府|习|术|历|制|士|位|期|年|系|生|长|姐|科|问|会|员|费|派|说)|(?<!优|典)雅思(?!维|想)|(?<!衬|拜|重)托福(?!利)|(?<!全|成|周|保|齐|万)全奖(?!励|金|杯|项|券|罚|惩|券|品|项|状)|(?<!一|相|减|过)半奖(?!励|金|杯|项|券|罚|惩|券|品|项|状)|(?<!学|高|院|技|上|中|少|军)校代(?!理|表|工|购|销|售)|(?<!中|华|精|比|爱|不|肥|甜)美高(?!级|等|兴|尚|山|大)|(?<!中|华|精|比|爱|不|肥|甜)美研(?!研|发|习)|(?<!中|华|精|比|爱|不|肥|甜)美本(?!来|该|人|界|色|意)|(?<!主|报|补|备|高|中)考培(?!训|养|育|植)|(?<!英|日|法|德|韩|汉|俄|西班牙|意大利|荷兰)语培(?!训|养|育|植)|(?<!主|报|补|备|高|中)考陪(?!伴|同|训|养|育|植)|(?<!英|日|法|德|韩|汉|俄|西班牙|意大利|荷兰)语陪(?!伴|同|训|养|育|植)|(?<!重|延|引|甲|庚)申研(?!研)|(?<!重|延|引|甲|庚)申博(?!士|学|弈)|(?<!一|笔|正|平|曲)直申(?!请|张|报|辩|明|诉|讨|领)|(?<!本|当|大|天)地接(?!待|班|吻|头|任|着|收|受|应|手|口)|(?<!打|做|收|分|加|开)工签(?!证|约|单|收|署|字|订|名)|(?<!香|中|空|海|军|张家|自由|舟山)港大(?!桥|路|海|陆|气|度|智|妈|选|叔|限|肆)|(?<!石|着|弄)墨大(?!桥|路|海|陆|气|度|智|妈|选|叔|限|肆)|(?<!大|延|重|同)庆大(?!桥|路|海|陆|气|度|智|妈|选|叔|限|肆)|(?<!大|延|重|同|婚|国|喜)庆应(?!该)|(?<!拖|外|伸)延大(?!桥|路|海|陆|气|度|智|妈|选|叔|限|肆)|(?<!拖|外|伸)延世(?!界)|(?<!大|延|重|同|婚|国|喜)庆熙(?!攘)|(?<!草|火|炸|医|用|中|西)药学(?!校|院|府|习|术|历|制|士|位|期|年|系|生|长|姐|科|问|会|员|费|派|说)|(?<!职)高商(?!业|品|场|家|城|户|行|号|标|机|情|界|会|量|订|誉|丘|人|船|队|数)/i'; $str = '法国高商值得去吗?我想去港大考培可以吗职业学院EB5收到英庆应庆大学习IB课程'; preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0); // Print the entire match result var_dump($matches);

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 PHP, please visit: http://php.net/manual/en/ref.pcre.php