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

re = /^.*?([\d.]+\s*(x|х)\s*[\d.]+\s*\/.*ET-?\d+).*$/m str = '1) София 5.5.x13/4x98 ET35 2) Палладика 7x16/5x139.7 D98 ET5 Алмаз черный 3) 35TH Anniversary 8x18/5x108 ET27 Black 4)Уран 6x14/4x108 ET37 1) NG277 5.5x13/4x100 D73.1 ET38 BKF = 5.5x13/4x100 D73.1 ET38 2) MC7/B 7x17/5x114.3 D70.6 ET54 Silver = 7x17/5x114.3 D70.6 ET54 3) S 7 Modify 7.5x18/5x112 D73 ET42 Silver = 7.5x18/5x112 D73 ET42 4) MK-Course Mod.08 7.5x18/5x100 D56.1 ET55 5) Fever-5R 8x18/5x120 D74.1 ET15 Black Mirror 6) R6162 9x20/5x108 D67.1 ET40 S 7) 35 Anniversary 8x18/5x120 ET34 Black 8) Lounge 8 & 10 8x18/5x110 D75 ET38 Black 9) RSL 5068TL 8.5x18/5x112 D71.6 ET40 MLB 10 Килиманджаро-5-оригинал 6x15/5x114.3 D67.1 ET52.5 11) RK L31F 6x15/4x100 D54.1 ET48 S 12 X-113 7x17/5x115 D70.1 ET41 BK/FP H-323 8x15/6x139.7 H-323 8x15/6x139.7 D110.5 ET-28 HS D/P H-526 7x15/6x139.7 D110.5 ET-13 HS LS182 10x15/5x139.7 D108.5 ET-40 BKF Талисман-Мега 7х16/5x139.7 D95.3 ET35 блэк платинум P0457 8.5 x 20/5x100 D73.1 ET35 Chrome 7100 7x16/6x139.7 D112.2 ET-15 Silver' subst = '\\1' result = str.gsub(re, subst) # Print the result of the substitution puts 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 Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html