https://wiki.cabal.mx/index.php?title=Curso_de_Programaci%C3%B3n_en_Python/RegEx-6&feed=atom&action=historyCurso de Programación en Python/RegEx-6 - Historial de revisiones2024-03-29T09:37:49ZHistorial de revisiones para esta página en el wikiMediaWiki 1.32.1https://wiki.cabal.mx/index.php?title=Curso_de_Programaci%C3%B3n_en_Python/RegEx-6&diff=119314&oldid=prevRrc en 16:01 15 dic 20152015-12-15T16:01:30Z<p></p>
<p><b>Página nueva</b></p><div><pre><br />
Python 3.4.3 (default, Jul 1 2015, 18:38:11) <br />
[GCC 4.9.2] on linux<br />
Type "help", "copyright", "credits" or "license" for more information.<br />
>>> import re<br />
>>> Str1 = "La fecha 16 de Septiembre es muy importante en México" <br />
>>> Str2 = "La fecha de 16 Sep es muy importante en México"<br />
>>> Resultado = re.search( r"Sep(tiembre)?", Str1 )<br />
>>> print( Resultado )<br />
<_sre.SRE_Match object; span=(15, 25), match='Septiembre'><br />
>>> Resultado = re.search( r"Sep(tiembre)?", Str2 )<br />
>>> print( Resultado )<br />
<_sre.SRE_Match object; span=(15, 18), match='Sep'><br />
>>> <br />
<br />
Estamos usando el metacaracter '?' para coincidir a Septiembre escribo<br />
en forma larga y tambien en forma corta. El '?' coincide por 0 o mas veces.<br />
<br />
</pre></div>Rrc