Regular Expressions 101

Save & Share

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

/
/
mg

Test String

Substitution

Processing...

Code Generator

Generated Code

$re = '/(<(?!(li|ul))[^>]+) style=".*?"/m'; $str = '<p class="BodyTextIndent3"> <strong>[To do]</strong> Style we need to have work in Tech zone: “Body Text Indent 2” so that we can indent paragraphs under a sub-step or sub-bullet, such as a paragraph containing a graphic. </p> <ul style="margin:0pt; padding-left:0pt"> <li class="ListParagraph" style="margin-left:27.14pt; text-indent:0pt; padding-left:8.86pt; font-family:serif"> <span style="font-family:\'Metropolis Light\'">This is a first-level bullet item (that works right now) created by using the </span><strong><span style="font-family:\'Metropolis Light\'; ">List Paragraph and then clicking the Bullet button in the toolbar</span></strong><span style="font-family:\'Metropolis Light\'">. Then, if you want to create sub-bullets, just also press the Tab key, like this:</span> <ul style="margin-right:0pt; margin-left:0pt; padding-left:0pt"> <li class="ListParagraph" style="margin-left:28.4pt; text-indent:0pt; padding-left:7.6pt"> <span style="font-family:\'Metropolis Light\'">This is a sub-bullet by using the </span><strong><span style="font-family:\'Metropolis Light\'; ">List Paragraph style, using a bulleted list and then pressing Tab</span></strong><span style="font-family:\'Metropolis Light\'">. If you press Return now, you will get another sub-bullet.</span> <ul style="margin-right:0pt; margin-left:0pt; padding-left:0pt"> <li class="ListParagraph" style="margin-left:27.12pt; text-indent:0pt; padding-left:8.88pt"> <span style="font-family:\'Metropolis Light\'">This is a sub-bullet by using the </span><strong><span style="font-family:\'Metropolis Light\'; ">List Paragraph style, using a bulleted list and then pressing Tab twice</span></strong><span style="font-family:\'Metropolis Light\'">. If you press Return now, you will get another sub-sub-bullet.</span> </li> </ul> </li> </ul> </li> </ul> <p class="BodyText"> Following are some examples taken from the RA appendixes. We need enough styles so that we can get these to work on Tech zone: </p> <p class="BodyText"> To configure the cluster quorum settings: </p> <ol style="margin:0pt; padding-left:0pt"> <li class="ListParagraph" style="margin-left:33.8pt; text-indent:0pt; padding-left:2.2pt"> Configure quorum votes for Site 1: <ol style="margin-right:0pt; margin-left:0pt; padding-left:0pt; list-style-type:lower-latin"> <li class="ListParagraph" style="margin-left:33.8pt; text-indent:0pt; padding-left:2.2pt"> Open Failover Cluster Manager and select<span style="font-family:Cambria">&#xa0;</span><strong>More Actions</strong><span style="font-family:Cambria">&#xa0;</span>&gt;<span style="font-family:Cambria">&#xa0;</span><strong>Configure Cluster Quorum Settings</strong>. </li> <li class="ListParagraph" style="margin-left:33.8pt; text-indent:0pt; padding-left:2.2pt"> Complete the Configure Cluster Quorum Wizard, using the following guidelines: </li> </ol> </li> </ol>'; $subst = ""; $result = preg_replace($re, $subst, $str); echo "The result of the substitution is ".$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 PHP, please visit: http://php.net/manual/en/ref.pcre.php