- pattern
- the pattern used to scan.
- horizon
- the search limit.
Documentation for this section has not yet been entered.
Type Reason Java.Lang.IllegalStateException if the Scanner is closed. Java.Lang.IllegalArgumentException if horizon is less than zero.
Tries to find the pattern in the input between the current position and the specified horizon. Delimiters are ignored. If the pattern is found, the matched string will be returned, and the Scanner will advance to the end of the matched string. Otherwise, null will be returned and Scanner will not advance. When waiting for input, the Scanner may be blocked.
The Scanner's search will never go more than horizon code points from current position. The position of horizon does have an effect on the result of the match. For example, when the input is "123" and current position is at zero, findWithinHorizon(Pattern.compile("\\p{Digit}{3}"), 2) will return null, while findWithinHorizon(Pattern.compile("\\p{Digit}{3}"), 3) will return "123". horizon is treated as a transparent, non-anchoring bound. (refer to Java.Util.Regex.Matcher.UseTransparentBounds(bool) and Java.Util.Regex.Matcher.UseAnchoringBounds(bool))
A horizon whose value is zero will be ignored and the whole input will be used for search. In this situation, all the input may be cached.