Help with Regex/Find/Macro
-
Good morning!
Everyone, I couldn’t understand REGEX.
I believe there’s a REGEX solution (Find or Filter) to solve my problem.
I need Notepad++ to search line by line and find the lines that contain:- A word with all letters in uppercase (example: LTDA)
- A word with all letters in lowercase (example: and)
- A word with mixed lowercase and uppercase letters (except capitalized words) (for example, find: hoUse, HOuse, HousE)
but NOT find House.
This would require 3 Regex and/or 3 macros.
Example sentences:
My HouSe is Beautiful => Find “HouSe” and “is”
My House Is Beautiful => Ok, Don’t find anything
MY House IS Beautiful => Find “MY”, “IS”Thank you
-
@João-Borloth said in Help with Regex/Find/Macro:
Good morning!
Everyone, I couldn’t understand REGEX.
I believe there’s a REGEX solution (Find or Filter) to solve my problem.
I need Notepad++ to search line by line and find the lines that contain:- A word with all letters in uppercase (example: LTDA)
- A word with all letters in lowercase (example: and)
- A word with mixed lowercase and uppercase letters (except capitalized words) (for example, find: hoUse, HOuse, HousE)
but NOT find House.
This would require 3 Regex and/or 3 macros.
Example sentences:
My HouSe is Beautiful => Find “HouSe” and “is”
My House Is Beautiful => Ok, Don’t find anything
MY House IS Beautiful => Find “MY”, “IS”Thank you
Your example doesn’t quite match your statement. If, as per your statement, you want to find lines which contain one or more words that do not consist of a capital letter optionally followed by one or more lower case letters, then try:
(?-is)^(?!\u\l*+([^\w\r\n]+\u\l*+)*+[^\w\r\n]*$).*+
You can find them one by one, or click Find All to get a list.
If, as per your example, you want to find words that do not consist of a capital letter optionally followed by one or more lower case letters, try:
(?-is)\b(\u\l*+)?+\w++
I tried to cover likely cases involving punctuation, but test. I’m not promising it’s perfect. (Come to think of it, I’m sure these will not handle words with apostrophes correctly.)