Kotlin: v1.8.0
matching over text in js.txt.
all online regex matchers find this valid.
but kotlin is returning null, even documentation says it should compile to jvm pattern when run on jvm.
Not very much experience with regexs, any help is appreciated.
Hi there...I am very familiar with Regex and the following in scratch kotlin file does return a match correctly:
Copy code
import java.io.File
val text = File("/home/perpetual/Downloads/js.txt").readText()
val regex = "nma=function\\(\\w\\)(\\{.*?return b.join\\(\\\"\\\"\\)\\}\\;)".toRegex()
// println(text)
regex.findAll(text).forEach {
println(it.value)
}
Anonymike
04/13/2023, 12:02 AM
If you'd like to learn more about how this regex works, this is a very useful tool that gives an explanation of the entire regex:
https://regex101.com/r/X2Gkky/1
s
Shabinder Singh
04/13/2023, 1:09 AM
Its works if used in jvm directly, but not running in commonSrc in multiplatform for some reason.
a
Anonymike
04/13/2023, 4:37 AM
I see...I thought it was working in Java code, but not Kotlin by the wording. Is there a particular target you are unable to run it in?
Anonymike
04/13/2023, 4:37 AM
Different targets no doubt use different regex engines, but they should be configured to work similarly