Skips input that matches the specified pattern, ignoring delimiters. This method will skip input if an anchored match of the specified pattern succeeds.
If a match to the specified pattern is not found at the current position, then no input is skipped and a NoSuchElementException is thrown.
Since this method seeks to match the specified pattern starting at the scanner's current position, patterns that can match a lot of input (".*", for example) may cause the scanner to buffer a large amount of input.
Note that it is possible to skip something without risking a NoSuchElementException
by using a pattern that can match nothing, e.g., sc.skip("[ \t]*")
.
@param pattern a string specifying the pattern to skip over
@return this scanner
@throws NoSuchElementException if the specified pattern is not found
@throws IllegalStateException if this scanner is closed