Regex 如何删除超过x个单词的行?在记事本中++;正则表达式
我想为一个项目排序一个巨大的列表,我需要从包含超过4个单词的长列表中删除所有行。 有人知道我如何在记事本++中做到这一点吗?Regex 如何删除超过x个单词的行?在记事本中++;正则表达式,regex,notepad++,Regex,Notepad++,我想为一个项目排序一个巨大的列表,我需要从包含超过4个单词的长列表中删除所有行。 有人知道我如何在记事本++中做到这一点吗? 谢谢。你可以想出像这样的办法: ^(?:\b\w+[^\w\r\n]*){4,}$ # ^ - anchor the expression to the beginning of a line # (?: - a non capturing group # \b - a word boundary # \w+ - match word characters gree
谢谢。你可以想出像这样的办法:
^(?:\b\w+[^\w\r\n]*){4,}$
# ^ - anchor the expression to the beginning of a line
# (?: - a non capturing group
# \b - a word boundary
# \w+ - match word characters greedily
# [^\w\r\n] - do not match any of these character (classes)
# the construct {4,} repeats this pattern 4 or more times
# $ - match the end of the line
您需要打开多行
模式。请参阅。感谢@SebastianProske发现了原始表达式中的错误
\n?^(\S+[^\S\n]+){3,}\S+.*$
这在TextWrangler中有效;它可能在记事本++中工作 Gute Nacht-超过4个单词将是5个或更多单词的重复谢谢!效果很好:)通过自动整理所有不需要的垃圾,这将节省我70%的时间!