Re: Matching Pure Numeric and '' with Python re

2006-10-27 Thread Steve Holden
Wijaya Edward wrote: > Hi, > > Given this list: > > list = ['0123', '1A34' , '333-' , '' ] > > I want to match only this element > '0123' (pure numeric) and '' (empty element). > > Why this construct doesn't work? > > p = re.compile("''+|[0-9]+") >m = p.match(word) >

Matching Pure Numeric and '' with Python re

2006-10-27 Thread Wijaya Edward
Hi, Given this list: list = ['0123', '1A34' , '333-' , '' ] I want to match only this element '0123' (pure numeric) and '' (empty element). Why this construct doesn't work? p = re.compile("''+|[0-9]+") m = p.match(word) if m: print word, Nam