Anyone regex experts know how to include foreign c...
# announcements
p
Anyone regex experts know how to include foreign chars in this expression?
Copy code
"[^\\p{Alnum}]".toRegex().find("s.trim μεγιουνικουντ n/o/n a.lph.a n.um\"")
Works in Java with:
Copy code
p = Pattern.compile("[^\\p{Alnum}]", Pattern.UNICODE_CHARACTER_CLASS);
however do not see an equivalent in Kotlin
c
Pattern.compile("[^\\p{Alnum}]", Pattern.UNICODE_CHARACTER_CLASS).toRegex()
p
I'm working in a pure kotlin (multiplatform) environment, and that is not an option afaik
c
Ah, I see, in that case vote on this issue: https://youtrack.jetbrains.com/issue/KT-21094 There's also a work-around in the comments.
p
thanks for the insight adding this flag to the exp works! (?U)[^\p{Alnum}]
👍 1
Well, works on JVM so far. fails miserably on JS. apparently the regex strings have to be platform specific