RegEx filter not working in Sublime Text search

喜欢而已 提交于 2019-12-02 13:23:28

问题


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

  • Begins with at least one lowercase letter, followed by at least one capital letter, followed by at least one lowercase letter or capital letter
  • Appears between single quotes.
  • Contains no spaces, numbers, or non-alphabetical characters.

Here is my expression:

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

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?


回答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]+'

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



来源:https://stackoverflow.com/questions/42769386/regex-filter-not-working-in-sublime-text-search

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!