Square brackets in regexes are used for character classes. When you put a list of characters in square brackets, this matches one character that is one of the ones listed. So
[author]
matches one character, if it's a
, h
, o
, r
, t
, or u
. It does not look for the word author
. Putting ^
in front also looks for one character that isn't in the list:
[^author]
matches one character as long as it's not a
, h
, o
, r
, t
, or u
.
But the key thing here is that []
cannot be used to match words or other sequences. In your example,
@[^(author)(Autowired)(Override)(param)(SuppressWarnings)].*
the part in square brackets matches one character that is not (
, a
, u
, or any of the other characters that appear in the square brackets (many of those characters appear multiple times, but that doesn't affect anything).