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
No Match

r"
"
gm

Test String

Code Generator

Generated Code

using System; using System.Text.RegularExpressions; public class Example { public static void Main() { string pattern = @"\b(?:BP:?(?:-Sitting)?|Blood Pressure) \d+/\d+(?: \d+/\d+| \d+/\d+)*(?: sm| -Lw| cB| Jr|\ -aA| cs| -ic| ic| -RG| kA| -sL| BL| kc| am| -sH| sH| es| ts| np| 8s| ca| Pm| JE| so| cp| v8| Eu| -cp|\ Pm| EB| Fr| -Fr| -ms| -LN| -mT| -mk| -GF| -HO| Jp| wD| 8m| mc| -mc| Yr| -Lp| -ml| -LA| s/d| -aA| s/d|mmHg| mm Hg|\ mm hg.|.?)?|B/P - (?:Sys|Dias)tolic \d+|(?:Sys|Dias)tolic Blood Pressure \d+ \w+\b|(?<=Recorded )\d{1,2}[A-Za-z]{3}\d{4}\b|\d{1,2}/\d{1,2}/\d{2,}\b(?= BP| Blood Pressure)"; string input = @"Weight: 188 lbs ,Wt 124 Ib (56.2 kg) ,Height: 108.2 cm Weight: 20.9 kg BMI: 18 Lives with Father, Mother. ,Vials BP 120/75 Hu 52"" We 202 I (916 kg) BMI 36.95 kg/m 354 2 mi ,W197 Ib 8 oz (44.2 kg) SpO2 99% BMI 19.69 kg/m2 BSA 1.36 m2 ,Weight 316kg ,HT: 160 cm WT: 79.6 kg BMI: 31.09 ,Blood Pressure 106/63 02/27/2019,B/P - Systolic 104,B/P - Diastolic 72,BP-Sitting 109/70 mmHg,BP: 101/72 left arm, normal cuff, seated 123/76 on 09/25/2018,Systolic Blood Pressure 100 mmHg,Diastolic Blood Pressure 68 mmHg,BP 128/80 128/81 128/82 128/83,Pain scale 0 1-10 Oxygen sat % 95 % HR 83 /min BP 144/68 mm Hg Ht , . _ Repeat BP 130/80.Just now feeling she is sure she is feeling FM.Plans to bottlefeed ,Blood Pressure 106/64s/d 78th / 77th percentileqyy Left Arm Sitting ,Blood Pressure 114/76 s/d 77th 7 goth percentileqyyy Right Arm Sitting ,BP 130/82mmHg Pulse 78 Ht 1.753 m 5' 9"" Wt 78.019 kg 172 Ib BMI 25.39 kg/m2 ,BP 142/70 sm ,BP 129/87 -Lw ,BP 120/74 cB ,BP 150/80 Jr ,BP 128/80 104/58 120/84 136/78 ,nan, 07/20/18 Blood Pressure 112/54 , BP 10/30/17 1345 178/80 ,Name 06/22/2018 06/22/2018 Blood Pressure 120/68 ,4/6/2015 BP 132/69 Patient Position ,nan,nan, Blood Pressure 150/88 Recorded 08Dec2017 02 49PM , Blood Pressure 150/88 Recorded 08Dec2017 02 49PM , Blood Pressure 140/88 Recorded 15Nov2017 03 21PM"; RegexOptions options = RegexOptions.Multiline; foreach (Match m in Regex.Matches(input, pattern, options)) { Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index); } } }

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 C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx