【发布时间】:2013-04-23 12:50:52
【问题描述】:
我想查找字符串中每次出现单个字母字符的所有索引。我不想捕获单个 char html 代码。
这是我的代码:
import re
s = "fish oil B stack peanut c <b>"
words = re.finditer('\S+', s)
has_alpha = re.compile(??????).search
for word in words:
if has_alpha(word.group()):
print (word.start())
期望的输出:
9
24
【问题讨论】:
-
感谢所有提供帮助的正则表达式天才。
标签: python regex character alphabetical