Regular Expressions 101

Save & Share

  • Regex Version: ver. 1
  • 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 = '/(\/.{1,}:.+|^Null|^VLAN)/m'; $str = 'GigaEthernet0/5 GigaEthernet0/6 GigaEthernet0/45 GigaEthernet0/3 GigaEthernet0/1 GigaEthernet0/2 VLAN10 EPON110/111 EPON0/2 EPON0/3 EPON0/4 EPON0/1:1 EPON0/10:2 EPON0/20:3 EPON0/1:4 EPON0/1:5 EPON0/1:6 EPON0/1:7 EPON0/111:8 EPON0/1:9 EPON0/1:10 EPON0/1:11 EPON0/1:12 EPON0/1:13 EPON0/1:14 EPON0/1:15 EPON0/1:16 EPON0/1:17 EPON0/1:18 EPON0/1:19 EPON0/1:20 EPON0/1:21 EPON0/1:22 EPON0/1:23 EPON0/1:24 EPON0/1:25 EPON0/1:26 EPON0/1:27 EPON0/1:28 EPON0/1:29 EPON0/1:30 EPON0/1:31 EPON0/1:32 EPON0/1:33 EPON0/1:34 EPON0/1:35 EPON0/1:36 EPON0/1:37 EPON0/1:38 EPON0/1:39 EPON0/1:40 EPON0/1:41 EPON0/1:42 EPON0/2:1 EPON0/2:2 EPON0/2:3 EPON0/2:4 EPON0/2:5 EPON0/2:6 EPON0/2:7 EPON0/2:8 EPON0/2:9 EPON0/2:10 EPON0/2:11 EPON0/2:12 EPON0/2:13 EPON0/2:14 EPON0/2:15 EPON0/2:16 EPON0/2:17 EPON0/2:18 EPON0/2:19 EPON0/2:20 EPON0/2:21 EPON0/3:1 EPON0/3:2 EPON0/3:3 EPON0/3:4 EPON0/3:5 EPON0/3:6 EPON0/3:7 EPON0/3:8 EPON0/3:9 EPON0/3:10 EPON0/3:11 EPON0/3:12 EPON0/3:13 EPON0/3:14 EPON0/3:15 EPON0/3:16 EPON0/3:17 EPON0/3:18 EPON0/3:19 EPON0/3:20 EPON0/3:21 EPON0/3:22 EPON0/3:23 EPON0/3:24 EPON0/3:27 EPON0/3:28 EPON0/3:29 EPON0/3:64 EPON0/4:1 EPON0/4:2 EPON0/4:3 EPON0/4:4 EPON0/4:5 EPON0/4:6 EPON0/4:7 EPON0/4:8 EPON0/4:9 EPON0/4:10 EPON0/4:11 EPON0/4:12 EPON0/4:13 EPON0/4:14 EPON0/4:15 EPON0/4:16 EPON0/4:17 EPON0/4:18 EPON0/4:19 EPON0/4:20 EPON0/4:21 EPON0/4:22 EPON0/4:23 EPON0/4:24 EPON0/4:25 EPON0/4:26 EPON0/4:27 EPON0/4:28 EPON0/4:29 EPON0/4:30 EPON0/4:31 EPON0/4:32 EPON0/4:33 EPON0/4:34 EPON0/4:35 EPON0/4:36 EPON0/4:37 EPON0/4:38 EPON0/4:39 EPON0/4:40 EPON0/4:41 EPON0/4:42 EPON0/4:43 EPON0/4:44 EPON0/4:45 EPON0/4:46 EPON0/4:47 EPON0/4:48 EPON0/4:49 EPON0/4:50 EPON0/4:51 EPON0/4:52 EPON0/4:53 EPON0/4:54'; 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