This topic created in 4327 days ago, the information mentioned may be changed or developed.
用的是python3.3.5 IDE是pycharm
我想取出标签、汉字、单词、数字、和空格
代码如下
import re
regex = re.compile("<[^>]*>|[\u4e00-\u9fa5]|[a-zA-Z]*|\d*|\s*")
print(regex.findall('''<i> bob是</i>25岁<br/>'''))
结果是
['<i>', '', 'bob', '是', '</i>', '', '', '岁', '<br/>', '']
想请教一下为什么数字25取不出来?
3 replies 2014-06-21 17:48:03 +08:00  | | 1 forreal Jun 21, 2014 第二行代码改为 regex = re.compile(r"<[^>]*>|[\u4e00-\u9fa5]|[a-zA-Z]*|\d*") 还是取不到数字25 |
 | | 2 czheo Jun 21, 2014 1 把所有的* 改成+ 试试 |