%d not working in re at Python 2.7?

V

vacu

I am frustrated to see %d not working in my Python 2.7 re.search, like
this example:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'group'


\d works fine:
'78'


And google search ignores % in their search, so I failed to find
answer from Python mailing list or web,
Do you have any idea what's problem here?

Thanks a head
Vacu
 
J

Josh McGee

%

I am frustrated to see %d not working in my Python 2.7 re.search, like
this example:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'group'


\d works fine:

'78'


And google search ignores % in their search, so I failed to find
answer from Python mailing list or web,
Do you have any idea what's problem here?

Thanks a head
Vacu

%d and %s and such are format strings, not regex.
 

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,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top