正则表达式过滤器在 Sublime Text 搜索中不起作用 [英] RegEx filter not working in Sublime Text search

查看:54
本文介绍了正则表达式过滤器在 Sublime Text 搜索中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Sublime 项目中找到所有满足以下条件的驼峰式字符串:

I'm trying to find all the camel case strings in a Sublime project that meet the following criteria:

  • 以至少一个小写字母开头,后跟至少一个大写字母,后跟至少一个小写字母或大写字母
  • 出现在单引号之间.
  • 不包含空格、数字或非字母字符.

这是我的表达:

('[a-z]{1,}[A-Z]{1,}[a-zA-Z]{1,}')

这在 RegExr 模拟器中可以完美运行,但是在 Sublime Text 的搜索中,它返回各种字符串,有的全部大写,有的全部小写.我错过了什么吗?

This works perfectly in the RegExr simulator, but in Sublime Text's search, it returns all kinds of strings, some in all caps, some all lowercase. Am I missing something?

推荐答案

我建议使用 (?-i)(?-i:...) 以避免选项出现问题,并使用 + 而不是 {1,} 提高可读性(恕我直言).

I suggest turning off case insensitivity inside the regex pattern with (?-i) or (?-i:...) to avoid issues with the options, and also using a + instead of {1,} increases readability (IMHO).

'(?-i)[a-z]+[A-Z][A-Za-z]+'

即使未启用 Aa(区分大小写的搜索),模式仍以区分大小写的方式处理.

Even though the Aa (case sensitive search) is not enabled, the pattern is still handled in a case sensitive way.

这篇关于正则表达式过滤器在 Sublime Text 搜索中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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