I am wondering how to format this expression to work in Java: [^#]+[#]
(1 or more characters that are not a # followed by a #)
Using regexr.com (my favorite regex tool) this expression will get the following matches from this input text:
input:
aBc def AbC def dfe ABC
#
123
#
matches:
aBc def AbC def dfe ABC
#
123
#
However when using Scanner.next("[^#]+[#]")
I get the InputMismatchException
which I take it that it didn't find any matches? Do I need to escape characters? In C# I usually avoid this problem with the string literal @
.
What am I missing about java Scanner and regex? Thanks.