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

$re = '/(^(?P<line_num>[1-9]|1[0-9]|2[0-2])\b +)(?P<qa_type>(Q|A|[mM][rR][\.|:]? [a-zA-Z]+|[mM][rR][sS][\.|:]? [a-zA-Z]+|[mM][sS][\.|:]? [a-zA-Z]+|[mM][iI][sS][sS][\.|:]? [a-zA-Z]+|[dD][rR][\.|:]? [a-zA-Z]+))?([\.|:|\s]+)?(?P<type_text>\b.*)|[pP][aA][gG][eE] (?P<page_num>\d{1,3})/m'; $str = '1 sure I understand, in this figure, the bottom figure 2 below Paragraph 88 that you prepared, to describe 3 your combination of Mendelson \'799/Ohsaki, is it 4 intended to show the relative sizes of the various 5 components? 6 MR. SMITH: Objection; form. 7 A. No. I\'d say it\'s purely an 8 illustration to convey the concept of how one might 9 combined these elements in order to achieve the 10 benefits we\'ve spoken of, using the convex cover to 11 provide improved adhesion and improved -- I might as 12 well read from the declaration -- "improved adhesion 13 and detection and protection of the elements within." 14 Q. Okay. And if a sensor like the one 15 you showed in the bottom figure below Paragraph 88 16 were used to take a physiological measurement, do you 17 agree that the distribution of incoming light would 18 be different as compared to the same sensor with no 19 cover? 20 MR. SMITH: Objection; form. 21 A. Yes, I agree that the convex cover 22 creates refractive effects, which change the angles 4/25/2021 [Redacted Text] Vol II www.[Redacted Text].com [Redacted Text] 2021 [Redacted Text] Page 275 1 of propagation of the rays of light. We are look at 2 a diffuse light source, so there\'s many, many 3 different possible rays that could you considered. 4 But they all will experience the laws of refraction 5 and that changes the distribution. 6 Q. Let me now ask you about Paragraph 20 7 of your report. 8 Here, you\'re discussing the level of 9 ordinary skill in the art, correct? 10 A. That\'s correct. 11 Q. And you refer here -- this is the 12 first sentence. You say, "...a working knowledge of 13 physiological monitoring technologies." 14 Do you see that? 15 A. Yes. 16 Q. What did you mean when you said that 17 a person of ordinary skill in the art "would have 18 been someone with a working knowledge of 19 physiological monitoring technologies"? 20 MR. SMITH: Objection; form. 21 A. They would have some knowledge of 22 physiological monitoring technologies and would be 4/25/2021 [Redacted Text] Vol II www.[Redacted Text].com [Redacted Text] 2021 [Redacted Text] Page 276 15 Ms. Jones: Objection; Maserati are the best!. 16 mr stevENS Loves this! 17 Dr. doe: Objection; Ferrari are the best!. 4/25/2021 [Redacted Text] Vol II www.[Redacted Text].com [Redacted Text] 2021 [Redacted Text] Page 277'; preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0); // Print the entire match result var_dump($matches);

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 PHP, please visit: http://php.net/manual/en/ref.pcre.php