Reputation: 5182
I am using Java's Scanner to parse some text. Say I have set as a delimiter a variety of characters [@$]
With next I get the text till that delimiter, but I would like for a way to learn if parsing stopped because it found @ or because it found $.
Is there some way to do that? Or should I break it in two, as in try with the first delimiter, and if you fail try with the second?
Upvotes: 2
Views: 202
Reputation: 5182
Found it! :) You can use
scanner.findWithinHorizon("[\\@]", 2)
to see if @ was the delimeter found.
Upvotes: 1