Realmente no es tanto problema de python es que tu expresión regular esta mal formada. Te recomiendo leer algún tutorial de expresiones regulares.
*import re* * * *pattern = re.compile(r"([0-9]*)\s*(PALLETS|PALLET|BULTOS|BULTO|CAJAS|CAJA|UNIDADES|UNIDAD|CARTONES|CARTON)") * * * *assert pattern.match('50 PALLETS').groups() == ('50', 'PALLETS'), 'Fallo test 1'* *assert pattern.match('10 CAJAS').groups() == ('10', 'CAJAS'), 'Fallo test 2'* *assert pattern.match('1 CAJA').groups() == ('1', 'CAJA'), 'Fallo test 3'* *assert pattern.match('ZXVC') == None, 'Fallo test 4'* * * *print 'Paso todos los tests'* * * Adjunto un pequeño código, espero que te ayude. El 31 de mayo de 2013 17:58, Manuel A. Estevez Fernandez <stvz...@gmail.com>escribió: > Saludos a todos > > Debo extraer ciertos datos de un campo de texto los cuales pueden aparecer > en cualquier parte de la cadena. > > Dicho datos son por ejemplo: 50 PALLETS, 10 CAJAS, etc. > > Estoy haciendo la siguiente expresion regular para buscarlo > > [0-9]*\s*[PALLET[S]|BULTO[S]|CAJA[S]|UNIDAD[ADES]|CARTON[ES]] > > Sin embargo no me funciona como espero. ¿Me podrían echar una mano? > > > > by: > > ISC. Manuel Alejandro Estévez Fernández > > > _______________________________________________ > Python-es mailing list > Python-es@python.org > http://mail.python.org/mailman/listinfo/python-es > FAQ: http://python-es-faq.wikidot.com/ > >
_______________________________________________ Python-es mailing list Python-es@python.org http://mail.python.org/mailman/listinfo/python-es FAQ: http://python-es-faq.wikidot.com/