regx找到python 3.x中超过4个单词的单词

在字符串中,我想使用re模块查找长度大于4的所有单词。regx找到python 3.x中超过4个单词的单词

样品输入:This is good Python forum and its helping a lot to beginners.

输出:['Python','helping','beginners]

下面我试过,但它不工作:

match=re.findall(r'([\w]{4}).*',str1) 

回答:

查找其长度大于

所有单词

用下面的办法:

import re 

s = 'This is good Python forum and its helping a lot to beginners.'

result = re.findall(r'\w{5,}', s)

print(result)

输出:

['Python', 'forum', 'helping', 'beginners'] 

以上是 regx找到python 3.x中超过4个单词的单词 的全部内容, 来源链接: utcz.com/qa/265598.html

回到顶部