问题
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