Stephan Schroeder
10/02/2019, 10:32 AM"<test>.*</test>".toRegex()
.find("aaaa<test>5</test>aaaa<test>4</test>aaaa")
?.let { println("match: ${it.value}") }
doesn’t return the minimal first match <test>5</test>, but the longer one <test>5</test>aaaa<test>4</test> given that the documentation says: “Returns the first match of a regular expression” here: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/-regex/find.html
And unfortunately findAll equally just returns a single match instead of two. Is there a way for me to fix this?
Playground link: https://pl.kotl.in/HA-C02_GyindexOf
and substring
but using regexes would be nicer (I don’t want to reinvent the wheel)arekolek
10/02/2019, 10:36 AM.*?
Matej Drobnič
10/02/2019, 10:37 AM.*?
should workStephan Schroeder
10/02/2019, 10:38 AM.*?
does work 😃👍arekolek
10/02/2019, 10:38 AMMatteo Mirk
10/02/2019, 11:14 AM*
and ?
are greedy quantifiers.