# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"<a href\=\"([\w\.\-\/]+)\"><v:shape\stitle=\"([\w\s]+)\:*\s*([\w\.\-]+)\"\sfillcolor\=\"\#([\w\d]+)\""
test_str = "<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>"
subst = "$1|$2|$3|$4"
# You can manually specify the number of replacements by changing the 4th argument
result = re.sub(regex, subst, test_str, 0)
if result:
print (result)
# Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and 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 Python, please visit: https://docs.python.org/3/library/re.html