Regular Expressions 101

Save & Share

  • Regex Version: ver. 2
  • 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

/
/
gx

Test String

Code Generator

Generated Code

use strict; my $str = '1. Br J Biomed Sci. 2015;72(3):93-101. Effects of propofol and isoflurane on haemodynamics and the inflammatory response in cardiopulmonary bypass surgery. Sayed S, Idriss NK, Sayyedf HG, Ashry AA, Rafatt DM, Mohamed AO, Blann AD. Cardiopulmonary bypass (CPB) causes reperfusion injury that when most severe is clinically manifested as a systemic inflammatory response syndrome. The anaesthetic propofol may have anti-inflammatory properties that may reduce such a response. We hypothesised differing effects of propofol and isoflurane on inflammatory markers in patients having CBR Forty patients undergoing elective CPB were randomised to receive either propofol or isoflurane for maintenance of anaesthesia. CRP, IL-6, IL-8, HIF-1α (ELISA), CD11 and CD18 expression (flow cytometry), and haemoxygenase (HO-1) promoter polymorphisms (PCR/electrophoresis) were measured before anaesthetic induction, 4 hours post-CPB, and 24 hours later. There were no differences in the 4 hours changes in CRP, IL-6, IL-8 or CD18 between the two groups, but those in the propofol group had higher HIF-1α (P = 0.016) and lower CD11 expression (P = 0.026). After 24 hours, compared to the isoflurane group, the propofol group had significantly lower levels of CRP (P < 0.001), IL-6 (P < 0.001) and IL-8 (P < 0.001), with higher levels CD11 (P = 0.009) and CD18 (P = 0.002) expression. After 24 hours, patients on propofol had increased expression of shorter HO-1 GT(n) repeats than patients on isoflurane (P = 0.001). Use of propofol in CPB is associated with a less adverse inflammatory profile than is isofluorane, and an increased up-regulation of HO-1. This supports the hypothesis that propofol has anti-inflammatory activity. PMID: 26510263 [PubMed - indexed for MEDLINE] 11. Br J Biomed Sci. 2015;72(3):93-101. Effects of propofol and isoflurane on haemodynamics and the inflammatory response in cardiopulmonary bypass surgery. Sayed S, Idriss NK, Sayyedf HG, Ashry AA, Rafatt DM, Mohamed AO, Blann AD. Cardiopulmonary bypass (CPB) causes reperfusion injury that when most severe is clinically manifested as a systemic inflammatory response syndrome. The anaesthetic propofol may have anti-inflammatory properties that may reduce such a response. We hypothesised differing effects of propofol and isoflurane on inflammatory markers in patients having CBR Forty patients undergoing elective CPB were randomised to receive either propofol or isoflurane for maintenance of anaesthesia. CRP, IL-6, IL-8, HIF-1α (ELISA), CD11 and CD18 expression (flow cytometry), and haemoxygenase (HO-1) promoter polymorphisms (PCR/electrophoresis) were measured before anaesthetic induction, 4 hours post-CPB, and 24 hours later. There were no differences in the 4 hours changes in CRP, IL-6, IL-8 or CD18 between the two groups, but those in the propofol group had higher HIF-1α (P = 0.016) and lower CD11 expression (P = 0.026). After 24 hours, compared to the isoflurane group, the propofol group had significantly lower levels of CRP (P < 0.001), IL-6 (P < 0.001) and IL-8 (P < 0.001), with higher levels CD11 (P = 0.009) and CD18 (P = 0.002) expression. After 24 hours, patients on propofol had increased expression of shorter HO-1 GT(n) repeats than patients on isoflurane (P = 0.001). Use of propofol in CPB is associated with a less adverse inflammatory profile than is isofluorane, and an increased up-regulation of HO-1. This supports the hypothesis that propofol has anti-inflammatory activity. PMID: 26510263 [PubMed - indexed for MEDLINE]'; my $regex = qr/(?m)^\s*\d+\..*\R{2} # Get to the title (?<title>[^\n]*(?:\n(?!\n)[^\n]*)*) # Get title \R{2} # Get to the authors [^\n]*(?:\n(?!\R)[^\R]*)* # Consume authors (?<abstract>[^\[]*(?:\[(?!PubMed[ ]-[ ]indexed[ ]for[ ]MEDLINE\])[^\[]*)*) # Grab abstract/xp; if ( $str =~ /$regex/g ) { print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n"; # print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n"; # print "Capture Group 2 is $2 ... and so on\n"; } # ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p' # Named capture groups can be called via $+{name}

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 Perl, please visit: http://perldoc.perl.org/perlre.html