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

Substitution

Processing...

Code Generator

Generated Code

const regex = new RegExp('^(\\d{1,3}(?:\\.\\d{1,3}){3})\\s*-\\s*((?1))\\s*-\\s*((?:[0-9A-Fa-f]{2}[:-]){3,6}[0-9A-Fa-f]{2})\\s*-\\s*(\\d\\d/\\d\\d/\\d{4}\\s\\d\\d(?::\\d\\d){2}|NEVER EXPIRES|INACTIVE)\\s*-\\s*(\\w)\\s*-\\s*(.*)$', 'gm') const str = `Changed the current scope context to 192.25.200.0 scope. Type : N - NONE, D - DHCP B - BOOTP, U - UNSPECIFIED, R - RESERVATION IP ============================================================================================ IP Address - Subnet Mask - Unique ID - Lease Expires -Type -Name ============================================================================================ 192.25.200.4 - 255.255.255.192- 64-9e-f3-b3-81-d3 -01/08/2018 17:07:46 -D- BH1-WAP-01.local 192.25.200.5 - 255.255.255.192- 50-57-a8-30-11-f6 -01/08/2018 16:24:59 -D- BH1-WAP-03.local 192.25.200.6 - 255.255.255.192- f0-f7-55-df-c4-ff -01/08/2018 16:45:04 -D- BH1-WAP-02.local 192.25.200.7 - 255.255.255.192- 00-23-24-bb-ce-83 -04/08/2018 10:55:00 -D- CESTA1703043.LOCAL No of Clients(version 4): 4 in the Scope : 192.25.200.0. Command completed successfully. Changed the current scope context to 192.25.200.64 scope. Type : N - NONE, D - DHCP B - BOOTP, U - UNSPECIFIED, R - RESERVATION IP ============================================================================================ IP Address - Subnet Mask - Unique ID - Lease Expires -Type -Name ============================================================================================ 192.25.200.68 - 255.255.255.192- 28-94-0f-05-ac-6c -01/08/2018 03:14:46 -D- WAP-C12-01-1047.local No of Clients(version 4): 1 in the Scope : 192.25.200.64. Command completed successfully. Changed the current scope context to 192.28.211.0 scope. 192.28.211.27 - 255.255.255.0 -00-0a-13-00-00-00-00- NEVER EXPIRES -U- CFCameraNearlockers Changed the current scope context to 192.28.194.0 scope. 192.28.194.254 - 255.255.255.0 -00-48-32-95-85 - INACTIVE -N- bms`; const subst = `$1 ~ $2 ~ $3 ~ $4 ~ $5 ~ $6`; // The substituted value will be contained in the result variable const result = str.replace(regex, subst); console.log('Substitution result: ', result);

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 JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions