如何搜索一行中的单词之间的多个空格的出现 [英] How to search for occurrences of more than one space between words in a line
本文介绍了如何搜索一行中的单词之间的多个空格的出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何搜索一行中的单词之间的多个空格的发生
How to search for occurrences of more than one space between words in a line
1. this is a line containing 2 spaces
2. this is a line containing 3 spaces
3. this is a line containing multiple spaces first second three four
以上都是这个正则表达式的有效匹配项。我应该使用什么正则表达式?
All the above are valid matches for this regex. What regex should I use?
推荐答案
[ ]{2,}
SPACE(2或更多)
SPACE (2 or more)
您还可以检查这些空格之前和之后的话都跟着。 (不是标签或新行的其他空格)
You could also check that before and after those spaces words follow. (not other whitespace like tabs or new lines)
\w[ ]{2,}\w
相同,但您也可以选择(捕获)仅替换的任务的空格
the same, but you can also pick (capture) only the spaces for tasks like replacement
\w([ ]{2,})\w
或者看到空格之前和之后有什么,不仅字符字符(空格除外)
or see that before and after spaces there is anything, not only word characters (except whitespace)
[^\s]([ ]{2,})[^\s]
这篇关于如何搜索一行中的单词之间的多个空格的出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文