Regular Expressions 101

Save & Share

  • Regex Version: ver. 3
  • Update Regex
    ctrl+⇧+s
  • Save new Regex
    ctrl+s
  • Add to Community Library

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 = '/LIN[^L]*(?:L(?!IN)[^L]*)*/m'; $str = 'UNB+UNOA:2+094200005561400986LA:ZZ+MTEL+200406:1436+34906++++1\'UNH+112490+DELFOR:D:96A:UN\'BGM+241+2004060008796+9\'DTM+137:202004061436:203\'DTM+157:20200406:102\'DTM+36:20200206:102\'NAD+BY+FRSFA0222838V::92\'NAD+SE+000563X::92\'UNS+D\'NAD+CN+VP1::92++TEST+SK TEST:204 TEST:TEST 22:TEST ST TEST+++37540+FRA\'LIN+1+3+441344:IN\'PIA+1+7PK1150:VN\'IMD+++:::VO-VKMV 7PK1150 VP\'LOC+11+999\'LOC+159+999\'RFF+ON:P092303\'QTY+113:100.00:PC\'SCC+1\'DTM+2:20200116:102\'RFF+AAJ:P092303:100\'QTY+113:100.00:PC\'SCC+1\'DTM+2:20200206:102\'RFF+AAJ:P092304:100\'LIN+2+3+502107:IN\'PIA+1+3PK670:VN\'IMD+++:::VO-VKMV 3PK670 EDC\'LOC+11+999\'LOC+159+999\'RFF+ON:P088273\'QTY+113:300.00:PC\'SCC+1\'DTM+2:20190503:102\'RFF+AAJ:P088273:100\'LIN+3+3+502109:IN\'PIA+1+6PK970:VN\'IMD+++:::VO-VKMV 6PK970 EDC\'LOC+11+999\'LOC+159+999\'RFF+ON:P084470\'QTY+113:200.00:PC\'SCC+1\'DTM+2:20190422:102\'RFF+AAJ:P084470:100\'LIN+4+3+6DK1215:IN\'PIA+1+AVRRV50D1-VKMV 6DK1215:VN\'IMD+++:::6DK1215\'LOC+11+999\'LOC+159+999\'RFF+ON:P046369\'QTY+48:533.00:PC\'RFF+AAK:32299\'DTM+171:20181109:102\'QTY+113:533.00:PC\'SCC+1\'DTM+2:20190419:102\'RFF+AAJ:P046369:100\'LIN+5+3+6DK1320:IN\'PIA+1+AVRRV50D1-VKMV 6DK1320?+282:VN\'IMD+++:::6DK1320\'LOC+11+999\'LOC+159+999\'RFF+ON:P061903\'QTY+48:115.00:PC\'RFF+AAK:43146\'DTM+171:20181003:102\'QTY+113:104.00:PC\'SCC+1\'DTM+2:20181005:102\'RFF+AAJ:P061903:100\'QTY+113:104.00:PC\'SCC+1\'DTM+2:20181102:102\'RFF+AAJ:P062034:100\'UNS+S\'UNT+75+112490\'UNZ+1+34906\''; 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