Regular Expressions 101

Save & Share

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

/
/
gs

Test String

Code Generator

Generated Code

$re = '/(.*?)((\@Comment\{Annotation: key:START;\})|$)/s'; $str = '@Comment{Annotation: key:START;} @Comment{OriginalFile: path:F:\\Dropbox\\Literature\\FileSeperations\\RC_ARS_NewUniquesAlphaSep;} @Comment{OriginalFile: name:ASF_UniqueToCheck.bib;} % Encoding: UTF-16 @Comment{jabref-meta: databaseType:bibtex;} @Comment{Annotation: key:START;} @Comment{OriginalFile: path:F:\\Dropbox\\Literature\\FileSeperations\\RC_ARS_NewUniquesAlphaSep;} @Comment{OriginalFile: name:Author_A.bib;} % Encoding: UTF-16 @Article{Asbrink2000, author = {\\AA sbrink, Sara and Zickert, Agneta and Bratt, Johan and Gyllenhammar, Hans and Palmblad, Jan}, title = {{No effect of carvedilol on nitric oxide generation in phagocytes but modulation of production of superoxide ions.}}, journal = {Biochemical pharmacology}, year = {2000}, volume = {59}, number = {8}, pages = {1007--13}, month = apr, abstract = {Since carvedilol has been claimed to possess antioxidative effects, this drug might affect functional responses, including nitric oxide (NO) generation, of polymorphonuclear neutrophils (PMN) and macrophages. When we assessed the effects of carvedilol on PMN responses in vitro, we observed that carvedilol dose dependently modulated generation of superoxide ions by NADPH oxidase when induced by the formylpeptide formyl-methionyl-leucyl-phenylalanine (fMLP) or the phorbol ester phorbol myristate acetate. This effect was not coupled to diminished phospholipase C activity. In contrast to the effect on NADPH oxidase, neither the fMLP-elicited NO generation by PMN nor the response of the murine macrophage cell line J774 to lipopolysaccharide was affected. There was no evidence from cell-free assay systems that carvedilol is a scavenger for superoxide ions or NO. Moreover, carvedilol did not affect other reactions dependent on NO, e.g. spontaneous or fMLP-stimulated PMN migration or lipoxin A(4)-, fMLP-, or A23187-induced neutrophil cytotoxicity for human umbilical vein endothelial cells. Thus, these effects point to the possibility that carvedilol modulates the NADPH oxidase of PMN but leaves the nitric oxide synthase of phagocytes intact.}, issn = {0006-2952}, keywords = {1- and,1-receptors and non selectively,2-adrenoreceptors,Animals,Antihypertensive Agents,Antihypertensive Agents: pharmacology,Calcium,Calcium: metabolism,Carbazoles,Carbazoles: pharmacology,Cytochrome c Group,Cytochrome c Group: metabolism,Free Radical Scavengers,Free Radical Scavengers: pharmacology,GTP-Binding Proteins,GTP-Binding Proteins: metabolism,Humans,Leukocyte,Leukocyte: drug effects,Mice,Neutrophils: drug effects,Neutrophils: metabolism,Nitric Oxide: metabolism,Oxidation-Reduction,Phagocytes,Phagocytes: drug effects,Phagocytes: metabolism,Propanolamines,Propanolamines: pharmacology,Superoxides,Superoxides: metabolism,Type C Phospholipases,Type C Phospholipases: metabolism,antag-,antihypertensive drug that,carvedilol,carvedilol is a vasodilating,chemotaxis,endothelial cells,moreover,neutrophils,nitric oxide,onizes,selectively blocks,superoxide ions}, owner = {ASF_A}, pmid = {10692566}, timestamp = {2016.06.25}, url = {http://www.ncbi.nlm.nih.gov/pubmed/10692566}, }'; 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