给定一个简单的字符串,如 "@dasweo where you at?" 我想编写一个正则表达式来提取 "dasweo"。
我目前拥有的是:
print re.findall(r"@\w{*}", "@dasweo where you at?")
虽然这不起作用。谁能帮我解决这个问题?
请您参考如下方法:
去掉 {..} 大括号,它们不与 * 一起使用:
>>> re.findall(r"@\w*", "@dasweo where you at?")
['@dasweo']
仅使用具有固定数字的 {..} 量词:
\w{3}
例如,正好匹配 3 个字母。
