Python正则表达式不起作用

问题描述:

我正在使用以下代码:

downloadlink = re.findall("http://uploadir.com/u/(.*)\b", str(downloadhtml))

但是,当我传递以下字符串时:

However, when I pass it the following string:

<input type="text" value="http://uploadir.com/u/bb41c5b3" />

它什么也没找到,当我期待它找到:http://uploadir.com/u/bb41c5b3.我做错了什么?

It finds nothing, when I'm expecting it to find: http://uploadir.com/u/bb41c5b3. What am I doing wrong?

我已经使用 http://gskinner.com/RegExr/ 测试了正则表达式,它似乎是正确的.我在这里遗漏了什么吗?

I have tested the regex using http://gskinner.com/RegExr/ and it seems to be correct. Am I missing something here?

>>> import re
>>> html = '<input type="text" value="http://uploadir.com/u/bb41c5b3" />';
>>> regex = r'http://uploadir.com/u/([^"]+)'
>>> link = re.findall(regex, html)
>>> link
['bb41c5b3']
>>>