GREP:查找超过12个字符的行(不包括空格) [英] GREP: Find lines more than 12 characters excluding spaces

查看:72
本文介绍了GREP:查找超过12个字符的行(不包括空格)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 Sublime Text 3 中使用GREP搜索.我想查找所有超过12个字符的行,不包括空格.

I am using a GREP search in Sublime Text 3. I want to find all lines that are more than 12 characters, excluding spaces.

示例

Mac and Cheese
Peanut Butter and Jelly Sandwich

在上面的示例中,找不到 Mac and Cheese ,因为它恰好是12个字符(不包括空格).

In the above example, Mac and Cheese would not be found, because it's exactly 12 characters excluding spaces.

我该怎么做?

我可以使用以下内容查找所有超过12个字符的行.但我不确定如何排除空格:

I can use the following to find all lines that are more than 12 characters. But I am not sure how to exclude spaces:

(?<=.{13}).+

推荐答案

模式(?< =.{13}).+ 将断言左侧是13个字符,并且点也将匹配一个空格.然后它将匹配除空格以外的所有char 1次以上.

The pattern (?<=.{13}).+ will assert what is on the left is 13 characters and the dot will also match a space. Then it will match any char except a whitespace 1+ times.

您可以匹配水平空白字符,并重复13次或更多次匹配非空白字符,例如 \ S (或指定允许匹配的字符),然后再添加0+个水平空白字符./p>

You could match horizontal whitespace chars and repeat 13 or more times matching a non whitespace char for example \S (or specify what you would allow to match) followed by 0+ horizontal whitespace chars.

^\h*(?:\S\h*){13,}$

  • ^ 字符串的开头
  • \ h * 匹配0+次水平空白字符
  • (?:非捕获组
    • \ S \ h * 匹配非空格字符,然后匹配0+个水平空格字符
      • ^ Start of string
      • \h* Match 0+ times a horizontal whitespace char
      • (?: Non capturing group
        • \S\h* Match non whitespace char, then 0+ horizontal whitespace chars
        • 正则表达式演示

          这篇关于GREP:查找超过12个字符的行(不包括空格)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆