I am trying to find a particular pattern in my strings and my knowledge of regex is quite basic. To find lower case letters I can use [a-z0-9]+ but how would I go about finding the preceding and proceding characters?
Allowed examples:
(A), AB, ABC, [ABC], .AB' , @ABCD#. In essence only uppercase characters(any length), or uppercase(any length) with preceding or proceding or both(front and back), special chars.
Not Allowed:
abABCaa , ABCaa , aaAB , 123ABC , 12ABGGabc , aaBaa etc. In essence uppercase letters(any length) with preceding or proceding or both, alphabets or numbers.
How can I write a regex that filters either the allowed examples or the not allowed examples?
Hope I am clear
This will match 3 groups: the Matched uppercase, the characters preceding it and the characters after it. If groups are not desired, just remove the parenthesis.
For more information about matching and grouping please refer to the proper Javadoc .
Also, a suggestion for testing regex online