Matching Pure Numeric and '' with Python re

W

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,

Namely it doesn't print 0123 and ''.
What's wrong with my regex?

-- Edward WIJAYA
SINGAPORE

------------ Institute For Infocomm Research - Disclaimer -------------
This email is confidential and may be privileged. If you are not the intended recipient, please delete it and notify us immediately. Please do not copy or use it for any purpose, or disclose its contents to any other person. Thank you.
--------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top