I am searching for a very specific regex expression that will help me find strings that meet the following rules:
- The string must contain the keyword 'Year' or 'YEAR'
- The keyword needs to be separated from other text by non-letters OR the keyword is in all caps or first letter capitalized in a string that is otherwise mixed cased.
- The keyword must be either at the beginning or the end of the string.
For example, I would like the regex to match the following strings:
Order YEAR
OrderYear
Order_YEAR
ORDER_YEAR
order year
YEAR_Order
YearOrder
But not these:
orderyear
ORDERYEAR
yearning
Order_Year_Test
The only thing I could come up with so far is:
^YEAR|YEAR$|^Year|Year$
Which works for most things but returns the opposite output for the "order year" and "ORDERYEAR" examples. I need some sort of regex expresssion that expresses casing rules.
Specifically I am using ICU's regex library (but just general regex advice is fine).
Thanks for any help,