Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 如何删除超过x个单词的行?在记事本中++;正则表达式_Regex_Notepad++ - Fatal编程技术网

Regex 如何删除超过x个单词的行?在记事本中++;正则表达式

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

我想为一个项目排序一个巨大的列表,我需要从包含超过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 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%的时间!