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

/
/
gs

Test String

Code Generator

Generated Code

$re = '/(\w+\s+RN)(?:(?!\s(?:RN|VA|VM)).)*?(\w+\s+VA\w+)(?:(?!\s(?:RN|VA|VM)).)*?(\w+\s+VM\w+)/s'; $str = 'No no RN 0.998045 sabía saber VMII3S0 0.592869 como como CS 0.999289 se se P00CN000 0.465639 ponía poner VMII3S0 0.65 una uno DI0FS0 0.951575 error error RN actuar accion VMP00SM lavadora lavadora NCFS000 0.414738 hasta hasta SPS00 0.957698 error error VMP00SM que que PR0CN000 0.562517 conocí conocer VMIS1S0 1 esta este DD0FS0 0.986779 error error VA00SM y y CC 0.999962 es ser VSIP3S0 1 que que CS 0.437483 es ser VSIP3S0 1 muy muy RG 1 sencilla sencillo AQ0FS0 1 de de SPS00 0.999984 utilizar utilizar VMN0000 1 ! ! Fat 1 Todo todo DI0MS0 0.560961 un uno DI0MS0 0.987295 gustazo gustazo NCMS000 1 error error VA00SM cuando cuando CS 0.985595 estamos estar VAIP1P0 1 error error VMP00RM aprendiendo aprender VMG0000 1 para para SPS00 0.999103 emancipar emancipar VMN0000 1 nos nos PP1CP000 1 , , Fc 1 que que CS 0.437483 si si CS 0.99954 error error RN nos nos PP1CP000 0.935743 ponen poner VMIP3P0 1 facilidad facilidad NCFS000 1 con con SPS00 1 las el DA0FP0 0.970954 error error VMP00RM tareas tarea NCFP000 1 de de SPS00 0.999984 alla alla VASI1S0 la el DA0FS0 0.972269 casa casa NCFS000 0.979058 pues pues CS 0.998047 mejor mejor AQ0CS0 0.873665 que que PR0CN000 0.562517 mejor mejor AQ0CS0 0.873665 no no RN esta estar VASI1S0 lavando lavar VMP00SM . . Fp 1'; 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