Using Scanner in Java how can I hasNext(aString) where the string is not regex pattern?
- by Parris
Hi,
I am trying to do as my question states, sooo I have the following code which would find the match.
String test = scan.next();
if (test.equals("$let"))
return 1;
However, I would prefer to use hasNext as to not consume a token; however, when i do the following it fails.
if (scan.hasNext("$let"))
return 1;
I realize the when giving has next a variable it expects a pattern, but I thought if i don't have any regex symbols it should work. I also thought $ was possibly some regex symbol so I tried /$ however, that did not work!
Thanks for the help!