<p><br>
On May 14, 2012 7:06 PM, "vacu" <<a href="mailto:vacu001@gmail.com">vacu001@gmail.com</a>> wrote:<br>
><br>
> I am frustrated to see %d not working in my Python 2.7 re.search, like<br>
> this example:<br>
><br>
> >>> (re.search('%d', "asdfdsf78asdfdf")).group(0)<br>
> Traceback (most recent call last):<br>
>  File "<stdin>", line 1, in <module><br>
> AttributeError: 'NoneType' object has no attribute 'group'<br>
><br>
><br>
> \d works fine:<br>
><br>
> >>> (re.search('\d+', "asdfdsf78asdfdf")).group(0)<br>
> '78'<br>
><br>
><br>
> And google search ignores % in their search, so I failed to find<br>
> answer from Python mailing list or web,<br>
> Do you have any idea what's problem here?<br>
><br>
> Thanks a head<br>
> Vacu<br>
> --<br></p>
<p>There's no problem at all. This is re.search, not scanf. They aren't supposed to behave the same. In fact, the docs specifically describe how to simulate scanf using re because python doesn't have a scanf function.</p>