<@U4714S16G> Currently there's no way to do it wit...
# announcements
i
@evkaky Currently there's no way to do it with
Regex
class. You can resort to
java.util.regex.Pattern
API
Copy code
val pattern = "[0-9]+".toPattern()
val matcher = pattern.matcher(string).region(startIndex, string.length)
if (matcher.lookingAt()) { ... }
e
Thank you!!! Now I can write my own efficient lexer without pain with hand-written finite automatons for each token class. (I know about lexer generators, but I can’t use them in my code kata) But is there any chance that similar api will be added to the kotlin’s
Regex
?
@ilya.gorbunov come back, pls
i
You can have this api as an extension of Regex class, just call its
toPattern()
method and do the code above with the returned
Pattern
instance.
We could add something like that in the stdlib, but we need to investigate the use cases first to design API that suits them. Please open an issue in YouTrack (kotl.in/issue), and describe yours. Also it likely won't be crossplatform, 'cause JS regexps do not support such functionality.