We need
Bug 1906024 Comment 24 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
What "brand" of RegExp does Kotlin use? I tried to understand the docs on kotlinlang.org but there were multiple definitions which seemed to depend on what language Kotlin was implemented in. My worry is that this is likely to miss a wide variety of space-like characters. If [`\s` is like JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#white_space) then we're good, but if it's like Java—which seems more likely!—then [`\s` doesn't even include `no-break space \xA0`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/regex/Pattern.html), let alone any of the Unicode ones. What if you do this same attack using non-ASCII space-like characters? Or alternate them so there aren't "long runs" of any given one? In a Java-based world I think you have to replace `\s` with `[\h\v]` ```diff private fun String.replaceContinuousSpaces(): String { - val escapedCharactersRegex = "\\s+".toRegex() + val escapedCharactersRegex = "[\\h\\v]+".toRegex() return replace(escapedCharactersRegex, SPACE) } ```