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

$re = '/([가-힣]{2,}.*)\\\\x082[0-9]{7}.*petPtyInfCoVo/m'; $str = ' 4nW9d7DCkn(\\x010(\\x011\\x0201\\x03신\\x011\\x0820180525\\x03\\x02\\x0f410100012619998D0267\\x0f포메라니안\\x01C\\x03\\n 4nXgtZwuDD(\\x010(\\x011\\x0201두부\\x011\\x0820180520\\x03\\x02D0222말티즈 (몰티즈)\\x01C\\x03\\n 4nXTTaAcB1(\\x011(\\x011\\x0820210303\\x0820240303\\x1a올드 잉글리시 쉽독\\x0820210303\\x011\\x011\\x011\\x01Y\\x03\\x03\\x01\\x13\\x02\\x01\\x1dbody.petInfCoVo.petPtyInfCoVo\\x10\\x13\\x02\\x1e\\x0bparentIndex\\x02\\x04\\x01\\x08rowIndex\\x02\\x04\\x01ctrId\\x01\\x01\\x01\\tctrPtySeq\\x04\\x0f\\x01hisSeq\\x04\\x0f\\x01\\x08bizSysCd\\x01\\x01\\x01\\x07prctrNo\\x01\\x01\\x01polNo\\x01\\x14\\x01\\n 4nXb4V19kO(\\x011(\\x011\\x0820210311\\x0820240311\\x10비숑 프리제\\x0820210306\\x011\\x011\\x01Y\\x03\\x03\\x01\\x13\\x02\\x01\\x1dbody.petInfCoVo.petPtyInfCoVo\\x10\\x13\\x02\\x1e\\x0bparentIndex\\x02\\x04\\x01\\x08rowIndex\\x02\\x04\\x01ctrId\\x01\\x01\\x01\\tctrPtySeq\\x04\\x0f\\x01hisSeq\\x04\\x0f\\x01\\x08bizSysCd\\x01\\x01\\x01\\x07prctrNo\\x01\\x01\\x01polNo\\x01\\x14\\x01\\n 4nXgtZwk3x(\\x011(\\x011\\x0820210312\\x0820240312말티즈 (몰티즈)\\x0820210312\\x011\\x011\\x01Y\\x03\\x03\\x01\\x13\\x02\\x01\\x1dbody.petInfCoVo.petPtyInfCoVo\\x10\\x13\\x02\\x1e\\x0bparentIndex\\x02\\x04\\x01\\x08rowIndex\\x02\\x04\\x01ctrId\\x01\\x01\\x01\\tctrPtySeq\\x04\\x0f\\x01hisSeq\\x04\\x0f\\x01\\x08bizSysCd\\x01\\x01\\x01\\x07prctrNo\\x01\\x01\\x01polNo\\x01\\x14\\x01\\n 4nXV55LGCp(\\x011(\\x011\\x0820210304\\x0820240304\\x0f포메라니안\\x0820210304\\x011\\x011\\x01Y\\x03\\x03\\x01\\x13\\x02\\x01\\x1dbody.petInfCoVo.petPtyInfCoVo\\x10\\x13\\x02\\x1e\\x0bparentIndex\\x02\\x04\\x01\\x08rowIndex\\x02\\x04\\x01ctrId\\x01\\x01\\x01\\tctrPtySeq\\x04\\x0f\\x01hisSeq\\x04\\x0f\\x01\\x08bizSysCd\\x01\\x01\\x01\\x07prctrNo\\x01\\x01\\x01polNo\\x01\\x14\\x01\\n 4nXnKyeGXv(\\x011(\\x011\\x0820210317\\x0820240317\\x0f410100008154365\'웰시 코기 (펨브록 웰시 코기)\\x0820210316\\x011\\x011\\x011\\x01Y\\x03\\x03\\x01\\x13\\x02\\x01\\x1dbody.petInfCoVo.petPtyInfCoVo\\x10\\x13\\x02\\x1e\\x0bparentIndex\\x02\\x04\\x01\\x08rowIndex\\x02\\x04\\x01ctrId\\x01\\x01\\x01\\tctrPtySeq\\x04\\x0f\\x01hisSeq\\x04\\x0f\\x01\\x08bizSysCd\\x01\\x01\\x01\\x07prctrNo\\x01\\x01\\x01polNo\\x01\\x14\\x01\\n 토이 푸들\\x0820210322\\x011\\x011\\x011\\x01Y\\x03\\x03\\x01\\x13\\x02\\x01\\x1dbody.petInfCoVo.petPtyInfCoVo\\x10\\x13\\x02\\x1e\\x0bparentIndex\\x02\\x04\\x01\\x08rowIndex\\x02\\x04\\x01ctrId\\x01\\x01\\x01\\tctrPtySeq\\x04\\x0f\\x01hisSeq\\x04\\x0f\\x01\\x08bizSysCd\\x01\\x01\\x01\\x07prctrNo\\x01\\x01\\x01polNo\\x01\\x14\\x01\\n 4nXcR06aop(\\x011(\\x011\\x0820210315\\x0820240315\\x0f410100004563767*기타B/믹스견 (5kg 초과 15kg 이하)\\x0820210309\\x011\\x011\\x011\\x01Y\\x03\\x03\\x01\\x13\\x02\\x01\\x1dbody.petInfCoVo.petPtyInfCoVo\\x10\\x13\\x02\\x1e\\x0bparentIndex\\x02\\x04\\x01\\x08rowIndex\\x02\\x04\\x01ctrId\\x01\\x01\\x01\\tctrPtySeq\\x04\\x0f\\x01hisSeq\\x04\\x0f\\x01\\x08bizSysCd\\x01\\x01\\x01\\x07prctrNo\\x01\\x01\\x01polNo\\x01\\x14\\x01\\n (1) \\\\x0f.*\\*([가-힣]{2,}.*)\\\\x0820 (2)([가-힣]{2,}.*)\\\\x0820.*petPtyInfCoVo \\\\x011\\\\x0201.*x0820.*D0.*[가-힣].*\\\\x01.*\\\\x03 ([가-힣]{2}.[가-힣]{2})\\\\x08.*petPtyInfCoVo \\x0f([가-힣]{2,})\\x08.*petPtyInfCoVo \\\\x0f([가-힣]{2,})\\\\x08.*petPtyInfCoVo ([가-힣]{2}.[가-힣]{2})\\\\x08.*petPtyInfCoVo \\\\x011\\\\x0201.*x0820.*D0.*([가-힣]{2,}).\\( [0-9a-zA-Z]{10}\\t([A-Z가-힣\\s]{2,})\\n\','; 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