I am in my first few days of Regular Expression learning. I am trying to do a simple pattern match to find an occurrence of @@@XXX@@@ markers in my log file where XXX is an uppercase word with no spaces/numeric values allowed there (underscore allowed too). There can be no or multiple spaces between starting &&& and the actual word or the word and the terminating&&&. XXX is always Upper case and no spaces/numeric values allowed there (underscore is allowed).
Some allowed examples:
@@@CAT@@@
@@@ CAT@@@
@@@ CAT @@@
@@@ CAT_DOG @@@
I tried doing something like:
Pattern pattern = Pattern.compile("\\@{3}(\\s* \\w \\s*)\\@{3}");
Doesn’t it mean check for 3 instances of @ followed by o to n instances of space followed by a word followed again by o to n instances of space followed by 3 instances of @ ?
It captures the cases with @@ but does not capture where more than 3 @ are used.
How do I specify there are 3 and only 3 instances of @? ….And obviously I still have not plugged the uppercase restriction.
Try this: