Regular Expressions 101

Save & Manage Regex

  • Current Version: 1
  • Save & Share
  • Community Library

Flavor

  • PCRE2 (PHP)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java
  • .NET 7.0 (C#)
  • Rust
  • PCRE (Legacy)
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests
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
Processing...

Test String

Substitution
Processing...

Code Generator

Generated Code

# If you'd like to omit non-matching lines from the result; add ';d' to the end of the expression. sed -E 's/(\d*\.\d*)( lb \(\d*\.*\d* kg\))/\1/gm;t' <<< "Age Weight Length 0 7.4 lb (3.3 kg) 19.6\" (49.8 cm) 1 21.3 lb (9.6 kg) 29.8\" (75.7 cm) 2 27.5 lb (12.5 kg) 34.2\" (86.8 cm) 3 31.0 lb (14.0 kg) 37.5\" (95.2 cm) 4 36.0 lb (16.3 kg) 40.3\" (102.3 cm) 5 40.5 lb (18.4 kg) 43.0\" (109.2 cm) 6 45.5 lb (20.6 kg) 45.5\" (115.5 cm) 7 50.5 lb (22.9 kg) 48.0\" (121.9 cm) 8 56.5 lb (25.6 kg) 50.4\" (128 cm) 9 63.0 lb (28.6 kg) 52.5\" (133.3 cm) 10 70.5 lb (32 kg) 54.5\" (138.4 cm) 11 78.5 lb (35.6 kg) 56.5\" (143.5 cm) 12 88.0 lb (39.9 kg) 58.7\" (149.1 cm) 13 100.0 lb (45.3 kg) 61.5\" (156.2 cm) 14 112.0 lb (50.8 kg) 64.5\" (163.8 cm) 15 123.5 lb (56.0 kg) 67.0\" (170.1 cm) 16 134.0 lb (60.8 kg) 68.3\" (173.4 cm) 17 142.0 lb (64.4 kg) 69.0\" (175.2 cm) 18 147.5 lb (66.9 kg) 69.2\" (175.7 cm) 19 152.0 lb (68.9 kg) 69.5\" (176.5 cm) 20 155.0 lb (70.3 kg) 69.7\" (177 cm) "

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 SED, please visit: https://www.gnu.org/software/sed/manual/html_node/The-_0022s_0022-Command.html