Regular Expressions 101

Save & Share

Flavor

  • PCRE2 (PHP)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java
  • .NET 7.0 (C#)
  • Rust
  • PCRE (Legacy)
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests
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
Processing...

Test String

Code Generator

Generated Code

$re = '/(\(\"STRCONNEXION\"\)?.=?.*)\"(.*?)\"/m'; $str = '<SCRIPT LANGUAGE="VBScript" RUNAT=Server> \'Session_OnStart S\'ex�cute la premi�re fois qu\'un utilisateur utilise une page de votre application \'Session_OnEnd S\'ex�cute en cas de d�passement du d�lai de la session d\'un utilisateur ou quand celui-ci quitte votre application \'Application_OnStart S\'ex�cute une fois lorsque la premi�re page de votre application est utilis�e pour la premi�re fois par un utilisateur \'Application_OnEnd S\'ex�cute une fois lors de l\'arr�t du serveur Web Sub Session_OnStart \'Session("STRCONNEXION")="wowoowow" Session("STRCONNEXION")="wowoowow" \'Session("STRCONNEXION")="wowoowow" Session.Timeout = 240 Session("Connected") = 0 \' Utilisateur n\'est pas encore authentifie Session("langue") = "ita" \'Set Session("SiteId") HostToSiteId End Sub Sub Session_OnEnd Session.Abandon end Sub Sub Application_OnStart Application("Titre") = "GVI" \' Composants COM Application("AccesBannieres.Banniere") = "AccesBannieresGVI.Banniere" Application("AccesBatch.Batch") = "AccesBatchGVI.Batch" Application("AccesCheck.Check") = "AccesCheckGVI.Check" Application("AccesCibles.Cibles") = "AccesCiblesGVI.Cibles" Application("AccesCibles.Produits") = "AccesCiblesGVI.Produits" Application("AccesCommande.Commande") = "AccesCommandeGVI.Commande" Application("AccesCommunication.Communication") = "ACGVI.Communication" Application("AccesDepotVente.GestionCommande") = "AccesDepotVenteGVI.GestionCommande" Application("AccesDepotVente.InfosVo") = "AccesDepotVenteGVI.InfosVo" Application("AccesDepotVente.Mails") = "AccesDepotVenteGVI.Mails" Application("AccesEncheres.Administrateur") = "AccesEncheresGVI.Administrateur" Application("AccesEncheres.Cloture") = "AccesEncheresGVI.Cloture" Application("AccesEncheres.ListeCriteres") = "AccesEncheresGVI.ListeCriteres" Application("AccesEncheres.Utilisateur") = "AccesEncheresGVI.Utilisateur" Application("AccesFicheVO.FicheVO") = "AccesFicheVOGVI.FicheVO" Application("AccesInscriptions.Inscriptions") = "AIGVI.Inscriptions" Application("AccesListeVO.AlerteEmail") = "AccesListeVOGVI.AlerteEmail" Application("AccesListeVO.ListeCriteres") = "AccesListeVOGVI.ListeCriteres" Application("AccesListeVO.ListeCriteresDV") = "AccesListeVOGVI.ListeCriteresDV" Application("AccesListeVO.ListeVO") = "AccesListeVOGVI.ListeVO" Application("AccesListeVO.ListeVODV") = "AccesListeVOGVI.ListeVODV" Application("AccesLogin.Login") = "AccesLoginGVI.Login" Application("AccesMix.Mix") = "AccesMixGVI.Mix" Application("AccesParameters.Parameters") = "AccesParametersGVI.Parameters" Application("AccesPrevente.Prevente") = "AccesPreventeGVI.Prevente" Application("AccesPromotions.Administration") = "AccesPromotionsGVI.Administration" Application("AccesPromotions.Promotions") = "AccesPromotionsGVI.Promotions" Application("AccesReport.Reports") = "AccesReportGVI.Reports" Application("AccesStopAffaire.Administrateur") = "ASAGVI.Administrateur" Application("AccesStopAffaire.ListeCriteres") = "ASAGVI.ListeCriteres" Application("AccesStopAffaire.StopAffaire") = "ASAGVI.StopAffaire" Application("AccesSuiviHisto.SuiviHisto") = "AccesSuiviHistoGVI.SuiviHisto" Application("AccesVenteParLot.Administrateur") = "AVPLGVI.Administrateur" Application("AccesVenteParLot.ListeCriteres") = "AVPLGVI.ListeCriteres" Application("AccesVenteParLot.VenteParLot") = "AVPLGVI.VenteParLot" Application("AccesVisibilite.Visibilite") = "AccesVisibiliteGVI.Visibilite" \' Nombre de r�sultat par page dans la liste VO Application("PageToResult") = 20 End Sub Sub HostToSiteId Dim audiHost, vwHost, currentHost audiHost = "www.audi-lineos.it" vwHost = "www.vgilineos.it" currentHost = Request.ServerVariables("HTTP_HOST") If currentHost = audiHost Then Session("SiteId") = 1 Session("SiteName") = "Audi" End If If currentHost = vwHost Then Session("SiteId") = 2 Session("SiteName") = "VW" End If If currentHost = "localhost:8080" Then Session("SiteId") = 2 Session("SiteName") = "VW" End If End Sub </SCRIPT> '; 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