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

/
/
g

Test String

Substitution

Processing...

Code Generator

Generated Code

using System; using System.Text.RegularExpressions; public class Example { public static void Main() { string pattern = @"<a href\=\""([\w\.\-\/]+)\""><v:shape\stitle=\""([\w\s]+)\:*\s*([\w\.\-]+)\""\sfillcolor\=\""\#([\w\d]+)\"""; string substitution = @"$1|$2|$3|$4"; string input = @"<v:group coordsize=""1000px,1000px"" coordorig=""0px,0px"" style=""position:relative;top:20px;left:0px;width:700;height:400""><a href=""../Sybase.Central.cobis/sp_dbosp_ente.htm""><v:shape title=""stored procedure: dbo.sp_ente"" fillcolor=""#FF0000"" strokecolor=""#FF0000"" style=""position:absolute;cursor:hand;z-index:10;behavior:url(#default#VML);top:2;left:76;width:10;height:10;"" path=""m 750,750 l 750,-750, -750,-750, -750,750, 750,750 xe""><v:fill method=""linear sigma"" angle=""-135"" type=""gradient"" style=""behavior:url(#default#VML);"" /><span title=""stored procedure: dbo.sp_ente"" style=""white-space:nowrap;position:relative;top:17;left:-16.099999999999998;cursor:hand;font-family:verdana;font-size:10;z-index:9;background-color:white;"">sp_ente</span></v:shape></a><v:shape strokeweight=""1px"" style=""position:absolute;behavior:url(#default#VML);z-index:-1000;height:1000;width:1000;top:0;left:0;"" strokecolor=""gray"" path=""m 310,290 l 76,2 xe"" /><a href=""../Sybase.Central.cobis/sp_dbosp_resultados_bv.htm""><v:shape title=""stored procedure: dbo.sp_resultados_bv"" fillcolor=""#FF0000"" strokecolor=""#FF0000"" style=""position:absolute;cursor:hand;z-index:10;behavior:url(#default#VML);top:-22;left:310;width:10;height:10;"" path=""m 750,750 l 750,-750, -750,-750, -750,750, 750,750 xe""><v:fill method=""linear sigma"" angle=""-135"" type=""gradient"" style=""behavior:url(#default#VML);"" /><span title=""stored procedure: dbo.sp_resultados_bv"" style=""white-space:nowrap;position:relative;top:17;left:-36.8;cursor:hand;font-family:verdana;font-size:10;z-index:9;background-color:white;"">sp_resultados_bv</span></v:shape></a><v:shape strokeweight=""1px"" style=""position:absolute;behavior:url(#default#VML);z-index:-1000;height:1000;width:1000;top:0;left:0;"" strokecolor=""gray"" path=""m 310,290 l 310,-22 xe"" /><a href=""../Sybase.Central.cobis/table_dboba_fecha_proceso.htm""><v:shape title=""table: dbo.ba_fecha_proceso"" fillcolor=""#0000FF"" strokecolor=""#0000FF"" style=""position:absolute;cursor:hand;z-index:10;behavior:url(#default#VML);top:2;left:543;width:10;height:10;"" path=""m 750,750 l 750,-750, -750,-750, -750,750, 750,750 xe""><v:fill method=""linear sigma"" angle=""-135"" type=""gradient"" style=""behavior:url(#default#VML);"" /><span title=""table: dbo.ba_fecha_proceso"" style=""white-space:nowrap;position:relative;top:17;left:-36.8;cursor:hand;font-family:verdana;font-size:10;z-index:9;background-color:white;"">ba_fecha_proceso</span></v:shape></a><v:shape strokeweight=""1px"" style=""position:absolute;behavior:url(#default#VML);z-index:-1000;height:1000;width:1000;top:0;left:0;"" strokecolor=""gray"" path=""m 310,290 l 543,2 xe"" /><a href=""../Sybase.Central.cobis/table_dbocl_catalogo.htm""><v:shape title=""table: dbo.cl_catalogo"" fillcolor=""#0000FF"" strokecolor=""#0000FF"" style=""position:absolute;cursor:hand;z-index:10;behavior:url(#default#VML);top:52;left:76;width:10;height:10;"" path=""m 750,750 l 750,-750, -750,-750, -750,750, 750,750 xe""><v:fill method=""linear sigma"" angle=""-135"" type=""gradient"" style=""behavior:url(#default#VML);"" /><span title=""table: dbo.cl_catalogo"" style=""white-space:nowrap;position:relative;top:17;left:-25.299999999999997;cursor:hand;font-family:verdana;font-size:10;z-index:9;background-color:white;"">cl_catalogo</span></v:shape></a><v:shape strokeweight=""1px"" style=""position:absolute;behavior:url(#default#VML);z-index:-1000;height:1000;width:1000;top:0;left:0;"" strokecolor=""gray"" path=""m 310,290 l 76,52 xe"" /><a href=""../Sybase.Central.cobis/table_dbocl_moneda.htm""><v:shape title=""table: dbo.cl_moneda"" fillcolor=""#0000FF"" strokecolor=""#0000FF"" style=""position:absolute;cursor:hand;z-index:10;behavior:url(#default#VML);top:28;left:310;width:10;height:10;"" path=""m 750,750 l 750,-750, -750,-750, -750,750, 750,750 xe""><v:fill method=""linear sigma"" angle=""-135"" type=""gradient"" style=""behavior:url(#default#VML);"" /><span title=""table: dbo.cl_moneda"" style=""white-space:nowrap;position:relative;top:17;left:-20.7;cursor:hand;font-family:verdana;font-size:10;z-index:9;background-color:white;"">cl_moneda</span></v:shape></a><v:shape strokeweight=""1px"" style=""position:absolute;behavior:url(#default#VML);z-index:-1000;height:1000;width:1000;top:0;left:0;"" strokecolor=""gray"" path=""m 310,290 l 310,28 xe"" /><a href=""../Sybase.Central.cobis/table_dbocl_tabla.htm""><v:shape title=""table: dbo.cl_tabla"" fillcolor=""#0000FF"" strokecolor=""#0000FF"" style=""position:absolute;cursor:hand;z-index:10;behavior:url(#default#VML);top:52;left:543;width:10;height:10;"" path=""m 750,750 l 750,-750, -750,-750, -750,750, 750,750 xe""><v:fill method=""linear sigma"" angle=""-135"" type=""gradient"" style=""behavior:url(#default#VML);"" /><span title=""table: dbo.cl_tabla"" style=""white-space:nowrap;position:relative;top:17;left:-18.4;cursor:hand;font-family:verdana;font-size:10;z-index:9;background-color:white;"">cl_tabla</span></v:shape></a><v:shape strokeweight=""1px"" style=""position:absolute;behavior:url(#default#VML);z-index:-1000;height:1000;width:1000;top:0;left:0;"" strokecolor=""gray"" path=""m 310,290 l 543,52 xe"" /><a href=""../Sybase.Central.cob_atc/table_dbotc_adhesiones_e_resumen.htm""><v:shape title=""table: dbo.tc_adhesiones_e_resumen"" fillcolor=""#0000FF"" strokecolor=""#0000FF"" style=""position:absolute;cursor:hand;z-index:10;behavior:url(#default#VML);top:102;left:76;width:10;height:10;"" path=""m 750,750 l 750,-750, -750,-750, -750,750, 750,750 xe""><v:fill method=""linear sigma"" angle=""-135"" type=""gradient"" style=""behavior:url(#default#VML);"" /><span title=""table: dbo.tc_adhesiones_e_resumen"" style=""white-space:nowrap;position:relative;top:17;left:-52.9;cursor:hand;font-family:verdana;font-size:10;z-index:9;background-color:white;"">tc_adhesiones_e_resumen</span></v:shape></a><v:shape strokeweight=""1px"" style=""position:absolute;behavior:url(#default#VML);z-index:-1000;height:1000;width:1000;top:0;left:0;"" strokecolor=""gray"" path=""m 310,290 l 76,102 xe"" /><a href=""../Sybase.Central.cob_atc/table_dbotc_convert_cab.htm""><v:shape title=""table: dbo.tc_convert_cab"" fillcolor=""#0000FF"" strokecolor=""#0000FF"" style=""position:absolute;cursor:hand;z-index:10;behavior:url(#default#VML);top:78;left:310;width:10;height:10;"" path=""m 750,750 l 750,-750, -750,-750, -750,750, 750,750 xe""><v:fill method=""linear sigma"" angle=""-135"" type=""gradient"" style=""behavior:url(#default#VML);"" /><span title=""table: dbo.tc_convert_cab"" style=""white-space:nowrap;position:relative;top:17;left:-32.199999999999996;cursor:hand;font-family:verdana;font-size:10;z-index:9;background-color:white;"">tc_convert_cab</span></v:shape></a><v:shape strokeweight=""1px"" style=""position:absolute;behavior:url(#default#VML);z-index:-1000;height:1000;width:1000;top:0;left:0;"" strokecolor=""gray"" path=""m 310,290 l 310,78 xe"" /><a href=""../Sybase.Central.cob_atc/table_dbotc_convert_det.htm""><v:shape title=""table: dbo.tc_convert_det"" fillcolor=""#0000FF"" strokecolor=""#0000FF"" style=""position:absolute;cursor:hand;z-index:10;behavior:url(#default#VML);top:102;left:543;width:10;height:10;"" path=""m 750,750 l 750,-750, -750,-750, -750,750, 750,750 xe""><v:fill method=""linear sigma"" angle=""-135"" type=""gradient"" style=""behavior:url(#default#VML);"" /><span title=""table: dbo.tc_convert_det"" style=""white-space:nowrap;position:relative;top:17;left:-32.199999999999996;cursor:hand;font-family:verdana;font-size:10;z-index:9;background-color:white;"">tc_convert_det</span></v:shape></a><v:shape strokeweight=""1px"" style=""position:absolute;behavior:url(#default#VML);z-index:-1000;height:1000;width:1000;top:0;left:0;"" strokecolor=""gray"" path=""m 310,290 l 543,102 xe"" /><a href=""../Sybase.Central.cob_atc/table_dbotc_cuentas_acmc.htm""><v:shape title=""table: dbo.tc_cuentas_acmc"" fillcolor=""#0000FF"" strokecolor=""#0000FF"" style=""position:absolute;cursor:hand;z-index:10;behavior:url(#default#VML);top:152;left:76;width:10;height:10;"" path=""m 750,750 l 750,-750, -750,-750, -750,750, 750,750 xe""><v:fill method=""linear sigma"" angle=""-135"" type=""gradient"" style=""behavior:url(#default#VML);"" /><span title=""table: dbo.tc_cuentas_acmc"" style=""white-space:nowrap;position:relative;top:17;left:-34.5;cursor:hand;font-family:verdana;font-size:10;z-index:9;background-color:white;"">tc_cuentas_acmc</span></v:shape></a><v:shape strokeweight=""1px"" style=""position:absolute;behavior:url(#default#VML);z-index:-1000;height:1000;width:1000;top:0;left:0;"" strokecolor=""gray"" path=""m 310,290 l 76,152 xe"" /><a href=""../Sybase.Central.cob_atc/table_dbotc_cuentas_amex.htm""><v:shape title=""table: dbo.tc_cuentas_amex"" fillcolor=""#0000FF"" strokecolor=""#0000FF"" style=""position:absolute;cursor:hand;z-index:10;behavior:url(#default#VML);top:128;left:310;width:10;height:10;"" path=""m 750,750 l 750,-750, -750,-750, -750,750, 750,750 xe""><v:fill method=""linear sigma"" angle=""-135"" type=""gradient"" style=""behavior:url(#default#VML);"" /><span title=""table: dbo.tc_cuentas_amex"" style=""white-space:nowrap;position:relative;top:17;left:-34.5;cursor:hand;font-family:verdana;font-size:10;z-index:9;background-color:white;"">tc_cuentas_amex</span></v:shape></a><v:shape strokeweight=""1px"" style=""position:absolute;behavior:url(#default#VML);z-index:-1000;height:1000;width:1000;top:0;left:0;"" strokecolor=""gray"" path=""m 310,290 l 310,128 xe"" /><a href=""../Sybase.Central.cob_atc/table_dbotc_cuentas_visa.htm""><v:shape title=""table: dbo.tc_cuentas_visa"" fillcolor=""#0000FF"" strokecolor=""#0000FF"" style=""position:absolute;cursor:hand;z-index:10;behavior:url(#default#VML);top:152;left:543;width:10;height:10;"" path=""m 750,750 l 750,-750, -750,-750, -750,750, 750,750 xe""><v:fill method=""linear sigma"" angle=""-135"" type=""gradient"" style=""behavior:url(#default#VML);"" /><span title=""table: dbo.tc_cuentas_visa"" style=""white-space:nowrap;position:relative;top:17;left:-34.5;cursor:hand;font-family:verdana;font-size:10;z-index:9;background-color:white;"">tc_cuentas_visa</span></v:shape></a><v:shape strokeweight=""1px"" style=""position:absolute;behavior:url(#default#VML);z-index:-1000;height:1000;width:1000;top:0;left:0;"" strokecolor=""gray"" path=""m 310,290 l 543,152 xe"" /><a href=""../Sybase.Central.cob_atc/table_dbotc_marca_uso.htm""><v:shape title=""table: dbo.tc_marca_uso"" fillcolor=""#0000FF"" strokecolor=""#0000FF"" style=""position:absolute;cursor:hand;z-index:10;behavior:url(#default#VML);top:202;left:76;width:10;height:10;"" path=""m 750,750 l 750,-750, -750,-750, -750,750, 750,750 xe""><v:fill method=""linear sigma"" angle=""-135"" type=""gradient"" style=""behavior:url(#default#VML);"" /><span title=""table: dbo.tc_marca_uso"" style=""white-space:nowrap;position:relative;top:17;left:-27.599999999999998;cursor:hand;font-family:verdana;font-size:10;z-index:9;background-color:white;"">tc_marca_uso</span></v:shape></a><v:shape strokeweight=""1px"" style=""position:absolute;behavior:url(#default#VML);z-index:-1000;height:1000;width:1000;top:0;left:0;"" strokecolor=""gray"" path=""m 310,290 l 76,202 xe"" /><a href=""../Sybase.Central.cob_atc/table_dbotc_rech_bajas_adh_e_resumen.htm""><v:shape title=""table: dbo.tc_rech_bajas_adh_e_resumen"" fillcolor=""#0000FF"" strokecolor=""#0000FF"" style=""position:absolute;cursor:hand;z-index:10;behavior:url(#default#VML);top:178;left:310;width:10;height:10;"" path=""m 750,750 l 750,-750, -750,-750, -750,750, 750,750 xe""><v:fill method=""linear sigma"" angle=""-135"" type=""gradient"" style=""behavior:url(#default#VML);"" /><span title=""table: dbo.tc_rech_bajas_adh_e_resumen"" style=""white-space:nowrap;position:relative;top:17;left:-62.099999999999994;cursor:hand;font-family:verdana;font-size:10;z-index:9;background-color:white;"">tc_rech_bajas_adh_e_resumen</span></v:shape></a><v:shape strokeweight=""1px"" style=""position:absolute;behavior:url(#default#VML);z-index:-1000;height:1000;width:1000;top:0;left:0;"" strokecolor=""gray"" path=""m 310,290 l 310,178 xe"" /><a href=""../Sybase.Central.cob_atc/table_dbotc_tarjetas.htm""><v:shape title=""table: dbo.tc_tarjetas"" fillcolor=""#0000FF"" strokecolor=""#0000FF"" style=""position:absolute;cursor:hand;z-index:10;behavior:url(#default#VML);top:202;left:543;width:10;height:10;"" path=""m 750,750 l 750,-750, -750,-750, -750,750, 750,750 xe""><v:fill method=""linear sigma"" angle=""-135"" type=""gradient"" style=""behavior:url(#default#VML);"" /><span title=""table: dbo.tc_tarjetas"" style=""white-space:nowrap;position:relative;top:17;left:-25.299999999999997;cursor:hand;font-family:verdana;font-size:10;z-index:9;background-color:white;"">tc_tarjetas</span></v:shape></a><v:shape strokeweight=""1px"" style=""position:absolute;behavior:url(#default#VML);z-index:-1000;height:1000;width:1000;top:0;left:0;"" strokecolor=""gray"" path=""m 310,290 l 543,202 xe"" /><a href=""../Sybase.Central.cob_atc/table_dbotc_tarjetas_acmc.htm""><v:shape title=""table: dbo.tc_tarjetas_acmc"" fillcolor=""#0000FF"" strokecolor=""#0000FF"" style=""position:absolute;cursor:hand;z-index:10;behavior:url(#default#VML);top:252;left:76;width:10;height:10;"" path=""m 750,750 l 750,-750, -750,-750, -750,750, 750,750 xe""><v:fill method=""linear sigma"" angle=""-135"" type=""gradient"" style=""behavior:url(#default#VML);"" /><span title=""table: dbo.tc_tarjetas_acmc"" style=""white-space:nowrap;position:relative;top:17;left:-36.8;cursor:hand;font-family:verdana;font-size:10;z-index:9;background-color:white;"">tc_tarjetas_acmc</span></v:shape></a><v:shape strokeweight=""1px"" style=""position:absolute;behavior:url(#default#VML);z-index:-1000;height:1000;width:1000;top:0;left:0;"" strokecolor=""gray"" path=""m 310,290 l 76,252 xe"" /><a href=""../Sybase.Central.cob_atc/table_dbotc_tarjetas_amex.htm""><v:shape title=""table: dbo.tc_tarjetas_amex"" fillcolor=""#0000FF"" strokecolor=""#0000FF"" style=""position:absolute;cursor:hand;z-index:10;behavior:url(#default#VML);top:228;left:310;width:10;height:10;"" path=""m 750,750 l 750,-750, -750,-750, -750,750, 750,750 xe""><v:fill method=""linear sigma"" angle=""-135"" type=""gradient"" style=""behavior:url(#default#VML);"" /><span title=""table: dbo.tc_tarjetas_amex"" style=""white-space:nowrap;position:relative;top:17;left:-36.8;cursor:hand;font-family:verdana;font-size:10;z-index:9;background-color:white;"">tc_tarjetas_amex</span></v:shape></a><v:shape strokeweight=""1px"" style=""position:absolute;behavior:url(#default#VML);z-index:-1000;height:1000;width:1000;top:0;left:0;"" strokecolor=""gray"" path=""m 310,290 l 310,228 xe"" /><a href=""../Sybase.Central.cob_atc/table_dbotc_tarjetas_visa.htm""><v:shape title=""table: dbo.tc_tarjetas_visa"" fillcolor=""#0000FF"" strokecolor=""#0000FF"" style=""position:absolute;cursor:hand;z-index:10;behavior:url(#default#VML);top:252;left:543;width:10;height:10;"" path=""m 750,750 l 750,-750, -750,-750, -750,750, 750,750 xe""><v:fill method=""linear sigma"" angle=""-135"" type=""gradient"" style=""behavior:url(#default#VML);"" /><span title=""table: dbo.tc_tarjetas_visa"" style=""white-space:nowrap;position:relative;top:17;left:-36.8;cursor:hand;font-family:verdana;font-size:10;z-index:9;background-color:white;"">tc_tarjetas_visa</span></v:shape></a><v:shape strokeweight=""1px"" style=""position:absolute;behavior:url(#default#VML);z-index:-1000;height:1000;width:1000;top:0;left:0;"" strokecolor=""gray"" path=""m 310,290 l 543,252 xe"" /><a href=""sp_dbosp_abmc_adhesiones_e_resumen.htm""><v:shape title=""stored procedure: dbo.sp_abmc_adhesiones_e_resumen"" fillcolor=""#FF0000"" strokecolor=""#FF0000"" style=""position:absolute;cursor:hand;z-index:10;behavior:url(#default#VML);top:290;left:310;width:10;height:10;"" path=""m 1000,1000 l 1000,-1000, -1000,-1000, -1000,1000, 1000,1000 xe""><v:fill method=""linear sigma"" angle=""-135"" type=""gradient"" style=""behavior:url(#default#VML);"" /><span title=""stored procedure: dbo.sp_abmc_adhesiones_e_resumen"" style=""white-space:nowrap;position:relative;top:22;left:-64.39999999999999;cursor:hand;font-family:verdana;font-size:10;z-index:9;background-color:white;"">sp_abmc_adhesiones_e_resumen</span></v:shape></a><a href=""../Sybase.Central.cob_atc/sp_dbosp_ac_adhesiones_e_resumen.htm""><v:shape title=""stored procedure: dbo.sp_ac_adhesiones_e_resumen"" fillcolor=""#FF0000"" strokecolor=""#FF0000"" style=""position:absolute;cursor:hand;z-index:10;behavior:url(#default#VML);top:340;left:135;width:10;height:10;"" path=""m 750,750 l 750,-750, -750,-750, -750,750, 750,750 xe""><v:fill method=""linear sigma"" angle=""-135"" type=""gradient"" style=""behavior:url(#default#VML);"" /><span title=""stored procedure: dbo.sp_ac_adhesiones_e_resumen"" style=""white-space:nowrap;position:relative;top:17;left:-59.8;cursor:hand;font-family:verdana;font-size:10;z-index:9;background-color:white;"">sp_ac_adhesiones_e_resumen</span></v:shape></a><v:shape strokeweight=""1px"" style=""position:absolute;behavior:url(#default#VML);z-index:-1000;height:1000;width:1000;top:0;left:0;"" strokecolor=""gray"" path=""m 310,290 l 135,340 xe"" /><a href=""../Sybase.Central.cob_remesas/sp_dbosp_eresumen_central.htm""><v:shape title=""stored procedure: asdwqeasfeqefef.sp_eresumen_central"" fillcolor=""#FF0000"" strokecolor=""#FF0000"" style=""position:absolute;cursor:hand;z-index:10;behavior:url(#default#VML);top:340;left:485;width:10;height:10;"" path=""m 750,750 l 750,-750, -750,-750, -750,750, 750,750 xe""><v:fill method=""linear sigma"" angle=""-135"" type=""gradient"" style=""behavior:url(#default#VML);"" /><span title=""stored procedure: dbo.sp_eresumen_central"" style=""white-space:nowrap;position:relative;top:17;left:-43.699999999999996;cursor:hand;font-family:verdana;font-size:10;z-index:9;background-color:white;"">sp_eresumen_central</span></v:shape></a><v:shape strokeweight=""1px"" style=""position:absolute;behavior:url(#default#VML);z-index:-1000;height:1000;width:1000;top:0;left:0;"" strokecolor=""gray"" path=""m 310,290 l 485,340 xe"" /></v:group>"; Regex regex = new Regex(pattern); string result = regex.Replace(input, substitution); } }

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 C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx