Hello! Is there method like in JavaScript match() ...
# getting-started
o
Hello! Is there method like in JavaScript match() which returns list by regex?
m
You can use something like
"<regexp>".toRegex().findAll("<string>")
which gives you a list of all matches found in the specified string not sure if this is what you need
d
match
in JS returns an array of groups that were matched, it doesn't return an array of matches (to find all matches in JS you need to call match repeatedly). The equivalent in Kotlin would be find, which returns a
MatchResult
, giving you access to the groups
1
o
The problem was in regex. I used the JS regex, but I had to change this to Java regex. Now it works even with method String.split(). BTW thank you for comments