Regular Expressions 101

Save & Manage Regex

  • Current Version: 1
  • Save & Share
  • Community Library

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

import java.util.regex.Matcher; import java.util.regex.Pattern; public class Example { public static void main(String[] args) { final String regex = "(\\(\\\"STRCONNEXION\\\"\\)?.=?.*)\\\"(.*?)\\\""; final String string = "<SCRIPT LANGUAGE=\"VBScript\" RUNAT=Server>\n\n" + "'Session_OnStart S'ex�cute la premi�re fois qu'un utilisateur utilise une page de votre application\n" + "'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\n" + "'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\n" + "'Application_OnEnd S'ex�cute une fois lors de l'arr�t du serveur Web\n\n" + "Sub Session_OnStart\n" + " 'Session(\"STRCONNEXION\")=\"wowoowow\" \n" + " Session(\"STRCONNEXION\")=\"wowoowow\"\n" + " 'Session(\"STRCONNEXION\")=\"wowoowow\" \n" + " Session.Timeout = 240\n" + " Session(\"Connected\") = 0 ' Utilisateur n'est pas encore authentifie\n" + " Session(\"langue\") = \"ita\"\n" + " 'Set Session(\"SiteId\")\n" + " HostToSiteId\n" + "End Sub\n\n" + "Sub Session_OnEnd\n" + " Session.Abandon\n" + "end Sub\n\n" + "Sub Application_OnStart\n\n" + " Application(\"Titre\") = \"GVI\"\n\n" + " ' Composants COM\n" + " Application(\"AccesBannieres.Banniere\") = \"AccesBannieresGVI.Banniere\"\n" + " Application(\"AccesBatch.Batch\") = \"AccesBatchGVI.Batch\"\n" + " Application(\"AccesCheck.Check\") = \"AccesCheckGVI.Check\"\n" + " Application(\"AccesCibles.Cibles\") = \"AccesCiblesGVI.Cibles\"\n" + " Application(\"AccesCibles.Produits\") = \"AccesCiblesGVI.Produits\"\n" + " Application(\"AccesCommande.Commande\") = \"AccesCommandeGVI.Commande\"\n" + " Application(\"AccesCommunication.Communication\") = \"ACGVI.Communication\"\n" + " Application(\"AccesDepotVente.GestionCommande\") = \"AccesDepotVenteGVI.GestionCommande\"\n" + " Application(\"AccesDepotVente.InfosVo\") = \"AccesDepotVenteGVI.InfosVo\"\n" + " Application(\"AccesDepotVente.Mails\") = \"AccesDepotVenteGVI.Mails\"\n" + " Application(\"AccesEncheres.Administrateur\") = \"AccesEncheresGVI.Administrateur\"\n" + " Application(\"AccesEncheres.Cloture\") = \"AccesEncheresGVI.Cloture\"\n" + " Application(\"AccesEncheres.ListeCriteres\") = \"AccesEncheresGVI.ListeCriteres\"\n" + " Application(\"AccesEncheres.Utilisateur\") = \"AccesEncheresGVI.Utilisateur\"\n" + " Application(\"AccesFicheVO.FicheVO\") = \"AccesFicheVOGVI.FicheVO\"\n" + " Application(\"AccesInscriptions.Inscriptions\") = \"AIGVI.Inscriptions\"\n" + " Application(\"AccesListeVO.AlerteEmail\") = \"AccesListeVOGVI.AlerteEmail\"\n" + " Application(\"AccesListeVO.ListeCriteres\") = \"AccesListeVOGVI.ListeCriteres\"\n" + " Application(\"AccesListeVO.ListeCriteresDV\") = \"AccesListeVOGVI.ListeCriteresDV\"\n" + " Application(\"AccesListeVO.ListeVO\") = \"AccesListeVOGVI.ListeVO\"\n" + " Application(\"AccesListeVO.ListeVODV\") = \"AccesListeVOGVI.ListeVODV\"\n" + " Application(\"AccesLogin.Login\") = \"AccesLoginGVI.Login\"\n" + " Application(\"AccesMix.Mix\") = \"AccesMixGVI.Mix\"\n" + " Application(\"AccesParameters.Parameters\") = \"AccesParametersGVI.Parameters\"\n" + " Application(\"AccesPrevente.Prevente\") = \"AccesPreventeGVI.Prevente\"\n" + " Application(\"AccesPromotions.Administration\") = \"AccesPromotionsGVI.Administration\"\n" + " Application(\"AccesPromotions.Promotions\") = \"AccesPromotionsGVI.Promotions\"\n" + " Application(\"AccesReport.Reports\") = \"AccesReportGVI.Reports\"\n" + " Application(\"AccesStopAffaire.Administrateur\") = \"ASAGVI.Administrateur\"\n" + " Application(\"AccesStopAffaire.ListeCriteres\") = \"ASAGVI.ListeCriteres\"\n" + " Application(\"AccesStopAffaire.StopAffaire\") = \"ASAGVI.StopAffaire\"\n" + " Application(\"AccesSuiviHisto.SuiviHisto\") = \"AccesSuiviHistoGVI.SuiviHisto\"\n" + " Application(\"AccesVenteParLot.Administrateur\") = \"AVPLGVI.Administrateur\"\n" + " Application(\"AccesVenteParLot.ListeCriteres\") = \"AVPLGVI.ListeCriteres\"\n" + " Application(\"AccesVenteParLot.VenteParLot\") = \"AVPLGVI.VenteParLot\"\n" + " Application(\"AccesVisibilite.Visibilite\") = \"AccesVisibiliteGVI.Visibilite\"\n\n" + " ' Nombre de r�sultat par page dans la liste VO\n" + " Application(\"PageToResult\") = 20\n\n" + "End Sub\n\n" + "Sub HostToSiteId\n\n" + " Dim audiHost, vwHost, currentHost\n\n" + " audiHost = \"www.audi-lineos.it\"\n" + " vwHost = \"www.vgilineos.it\"\n" + " currentHost = Request.ServerVariables(\"HTTP_HOST\")\n\n" + " If currentHost = audiHost Then\n" + " Session(\"SiteId\") = 1\n" + " Session(\"SiteName\") = \"Audi\"\n" + " End If\n\n" + " If currentHost = vwHost Then\n" + " Session(\"SiteId\") = 2\n" + " Session(\"SiteName\") = \"VW\"\n" + " End If\n\n" + " If currentHost = \"localhost:8080\" Then\n" + " Session(\"SiteId\") = 2\n" + " Session(\"SiteName\") = \"VW\"\n" + " End If\n\n" + "End Sub\n\n" + "</SCRIPT>\n\n\n\n\n\n"; final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE); final Matcher matcher = pattern.matcher(string); while (matcher.find()) { System.out.println("Full match: " + matcher.group(0)); for (int i = 1; i <= matcher.groupCount(); i++) { System.out.println("Group " + i + ": " + matcher.group(i)); } } } }

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 Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html