Regular Expressions 101

Save & Share

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

/
/
gm

Test String

Code Generator

Generated Code

$re = '/(.*(DET|NN*)*?)./m'; $str = 'வெ/NN கலைவாணன்/NN திருப்பத்தூர்/NN செய்தியாளர்/NN சிவகங்கை/NNP மாவட்டம்/NN. அழியும்/NNP நிலையில்/CNJ உள்ள/VNAJ விளையாட்டுக்களுக்கு/NN புத்துணர்வு/NN அளித்து/VNAV இருக்கிறது/VF கொரோனா/NN. சிவகங்கை/NNP மாவட்டம்/NN திருப்பத்தூர்/NNP அருகே/ADV கிராமப்புறப்/NN பகுதிகளில்/CNJ கொரோனா/NN தொற்றுநோய்/NN தடுப்பு/NNC நடவடிக்கையான/NNC ஊரடங்கு/NN உத்தரவால்/CNJ அழியும்/VNAV நிலையில்/CNJ உள்ள/VNAJ கிராமங்களில்/CNJ மண்மணம்/NN மாறாத/VNAJ பாரியம்பரியமிக்க/NN விளையாட்டுக்களுக்கு/NN புத்துணர்வு/NN அளித்து/VNAV இருக்கிறது/VF கொரோனா/NN தமிழ்நாட்டு/NNP கிராமங்களில்/CNJ மண்மணம்/NN மாறாத/VNAJ பாரியம்பரியமிக்க/NN விளையாட்டுக்களான/NN தாயம்/NN ஆடலாமா/NN சொட்டாங்கல்/NN விளையாடலாமா/NN என/CNJ இன்றைய/ADJ சிறுவர்களிடமோ/NN இளைஞர்களிடமோ/NN கேட்டால்/CVB அவர்கள்/PRP புரியாதது/NN போல்/PPO விழிப்பது/NN நாம்/PRP அறிந்ததே/ADJ. அந்த/DET அளவிற்கு/NN பாரம்பரிய/NNC விளையாட்டுக்கள்/NNC என்னவென்றே/NN தெரியாத/VNAJ நிலைதான்/NN இன்றைய/ADJ இளைஞர்களிடம்/NN உள்ளது/CNJ தற்போது/ADV. இந்த/DET விளையாட்டுக்கள்/NN அனைத்தும்/NN அருகி/VNAV விட்டன/NN. ஆனால்/CNJ இந்த/DET விளையாட்டுகளுக்கு/NN மீண்டும்/ADV உயிர்/NN கொடுத்துள்ளது/VF கொரோனா/NN ஊரடங்கு/NN. உத்தரவால்/CNJ வீட்டிற்குள்ளேயே/NN முடங்கிக்/VNAV கிடக்கும்/VNAJ கிராமத்தார்கள்/NN பாரம்பரியமிக்க/NN பழமையான/ADJ தனி/ADJ விளையாட்டான/NN தாயம்/NN விளையாடுதல்/NN பல்லாங்குழி/NN சொட்டாங்கல்/NN உள்ளிட்ட/ADJ விளையாட்டுக்களை/NN தனது/PRP வீட்டில்/CNJ உள்ள/VNAJ நபர்களுடன்/NN விளையாட/NN ஆரம்பித்துள்ளது/VF பழங்காலத்திற்கு/NN திரும்பியுள்ளதை/NN நினைவுபடுத்தியுள்ளது/NN. வயதானவர்கள்/NN தங்களது/PRP பேத்திகளுக்கு/NN சொல்லிக்/VNAV கொடுக்கும்/VNAJ தாயம்/NN விளையாட்டில்/CNJ தற்பொழுது/ADV மாணவர்களும்/NN குழந்தைகளும்/NN ஆர்வம்/NN காட்டி/VNAV வருகின்றனர்/NN. அதே/PRP போன்று/ADV கூட்டாக/ADV இல்லாமல்/VNAV வீட்டிற்குள்ளும்/NN வாசல்/CNJ முன்பு/ADV உள்ள/VNAJ மரநிழலில்/NN இதுபோன்ற/PRP பழமையான/ADJ விளையாட்டுகளிலும்/NN பெற்றோர்கள்/NN பாட்டிகள்/NN சகோதரிகள்/NN இணைந்து/VNAV விளையாடி/NN வருகின்றனர்/NN. கொரோனா/NN பல/NNQ விதத்தில/NN பிரச்சனை/NN என்றாலும்/COM பழமையான/ADJ விளையாட்டுகளை/NN சிறுவர்களுக்கு/CNJ கற்று/VNAV கொடுக்கும்/VNAJ நிலையை/NNC உருவாக்கியுள்ளது/VINT. '; 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