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
No Match

/
/
gm

Test String

Code Generator

Generated Code

use strict; my $str = ' IBAN BE12 6115 1361 7292 BIC DEUTBEBE 321,81 + VAL SOLDE LE 03/01 REF. 23/01 50,00 + 23/01 VIREMENT BE73 271 0141648 60 59991799 BIETLOT FRANCOIS RUE DE PRAHY 14 5060 SAMBREVILLE BE Com: CASH - ETRENNES AUGUSTIN MAMY GISOU 23/01 50,00 + 23/01 VIREMENT BE73 271 0141648 60 59991899 BIETLOT FRANCOIS RUE DE PRAHY 14 5060 SAMBREVILLE BE Com: CASH - NAISSANCE AUGUSTIN VALERIE 23/01 50,00 + 23/01 VIREMENT BE73 271 0141648 60 59991999 BIETLOT FRANCOIS RUE DE PRAHY 14 5060 SAMBREVILLE BE 471,81 + A REPORTER EXTRAIT 002/001 E-ACCOUNT 611-5136172-92 EUR 05/04/18 IBAN BE12 6115 1361 7292 BIC DEUTBEBE 471,81 + REPORT A NOUVEAU Com: CASH - ETRENNES AUGUSTIN NONO MAMYLINE 12/02 20,00 - 12/02 VOTRE VIREMENT A BE73 271 0141648 60 59997800 1.1 Bietlot François Com: /remb liquide/siege velo 451,81 + SOLDE LE 12/02 Les dépôts sur ce compte sont éligibles à la protection conformément à la loi allemande sur la garantie des dépôts. Vous trouverez plus d\'informations dans la Fiche d\'information du déposant disponible sur simple demande ou sur www.deutschebank.be/media/pdf/informatieblad-fr.pdf EXTRAIT 002/002 E-ACCOUNT 611-5136172-92 EUR 05/04/18 TAUX D\'INTERET DEBITEUR APPLIQUE : 5,87 % PAR AN. IBAN BE23 6115 1361 7191 BIC DEUTBEBE 732,12 + VAL SOLDE LE 04/01 REF. 09/01 400,00 + 09/01 VIREMENT BE73 750 6414221 60 59995699 BIETLOT FRANCOIS RUE DE PRAHY 14 5060 VELAINE-SUR-SAMBRE BE Com: RESERVE CHARGES 07/02 400,00 + 07/02 VIREMENT BE73 750 6414221 60 59998199 BIETLOT FRANCOIS RUE DE PRAHY 14 5060 VELAINE-SUR-SAMBRE BE Com: RESERVE CHARGES 07/03 400,00 + 07/03 VIREMENT BE73 750 6414221 60 59993099 BIETLOT FRANCOIS RUE DE PRAHY 14 5060 VELAINE-SUR-SAMBRE BE Com: RESERVE CHARGES 1.932,12 + SOLDE LE 07/03 EXTRAIT 002/001 DB INTENSIV PLUS 611-5136171-91 EUR 05/04/18 IBAN BE23 6115 1361 7191 BIC DEUTBEBE Les dépôts sur ce compte sont éligibles à la protection conformément à la loi allemande sur la garantie des dépôts. Vous trouverez plus d\'informations dans la Fiche d\'information du déposant disponible sur simple demande ou sur www.deutschebank.be/media/pdf/informatieblad-fr.pdf EXTRAIT 002/002 DB INTENSIV PLUS 611-5136171-91 EUR 05/04/18 IBAN BE65 6115 1361 7696 BIC DEUTBEBE 344,83 + VAL SOLDE LE 12/01 REF. 05/04 0,22 + 01/04 PRIME DE FIDELITE TRIMESTRE 1 90000799 345,05 + SOLDE LE 05/04 Les dépôts sur ce compte sont éligibles à la protection conformément à la loi allemande sur la garantie des dépôts. Vous trouverez plus d\'informations dans la Fiche d\'information du déposant disponible sur simple demande ou sur www.deutschebank.be/media/pdf/informatieblad-fr.pdf EXTRAIT 002/001 DB E-FIDELITY ACCOUNT 611-5136176-96 EUR 05/04/18 611-5136170-90 19.02.18 CREDITS TERMINAL : 403693/P2P MOBILE PERIODE : 048 00.00.00 --------------------------------------------------------------------------- TRANSACTION DATE/HEURE DONNEUR D\'ORDRE MONTANT REFERENCE --------------------------------------------------------------------------- 8984 17.02 20.06 001-7562717-91 46,40 P2P MOBILE TOTAL : 46,40 EUR DECOMPTE D\'INTERETS ET FRAIS 03M DATE : 01/04/2018 E-ACCOUNT 611-5136170-90 EUR 72/26 3,43 D INTERETS EN NOTRE FAVEUR 3,43 D MONTANT NET - VALEUR 01/04/2018 COMPTABILISE EN COMPTE DROIT DE TIMBRE EUR 0,15 PAYE PAR LA BANQUE DECOMPTE PRIME DE FIDELITE TRIMESTRE 1(*) DATE : 05/04/2018 DB E-Fidelity Account 611-5136176-96 EUR 72 0,22 C PRIME DE FIDELITE TRIMESTRE 1 0,22 C MONTANT NET - VALEUR 01/04/2018 COMPTABILISE EN COMPTE (*) LE MONTANT DE LA PRIME DE FIDELITE PEUT ETRE SUJET A DES MODIFICATIONS EN CAS DE MOUVEMENT A UNE DATE ULTERIEURE AYANT UNE DATE VALEUR DANS UN TRIMESTRE PRECEDENT. '; my $regex = qr/\s*(((\d*).?(\d*),(\d*)).*VAL.*SOLDE LE\s*((0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[012])))/mp; if ( $str =~ /$regex/g ) { print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n"; # print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n"; # print "Capture Group 2 is $2 ... and so on\n"; } # ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p' # Named capture groups can be called via $+{name}

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 Perl, please visit: http://perldoc.perl.org/perlre.html