Adam S
06/20/2023, 12:04 PMfun main() {
val r = Regex("""\h+([^:\v]+):""")
println(r.matchEntire(" Version:")?.groupValues)
// JVM: [ Version:, Version]
// JS: SyntaxError: Invalid regular expression: /\h+([^:\v]+):/gu: Invalid escape
}
https://pl.kotl.in/HwXS2Fv3u
EDIT: Ahh, never mind. \h (horizontal whitespace) doesn’t exist in JS. I’ll try replacing it with
[\t\x{00A0}\x{1680}\x{180E}\x{2000}\x{2001}\x{2002}\x{2003}\x{2004}\x{2005}\x{2006}\x{2007}\x{2008}\x{2009}\x{200A}\x{202F}\x{205F}\x{3000}]
(as found on https://regex101.com/)
further suggestions are welcome!Johann Pardanaud
06/20/2023, 12:15 PMVampire
06/20/2023, 12:44 PM\h and see that Java from version 8 on supports it while JavaScript does not.
And on https://www.regular-expressions.info/shorthand.html#more you sould then have a elaborate description and alternatives, so the replacement should be *[*\t\p{Zs}*]. Unfortunately \p... is POSIX class which is also not supported by JavaScript.* 😞
But on https://www.compart.com/de/unicode/category/Zs you can see which characters are part of Zs, so your replacement is almost correct, you just miss space and have additionally the "Mongolian Vowel Separator" which is not part of Zs.Johann Pardanaud
06/20/2023, 12:47 PMAdam S
06/20/2023, 4:33 PM[^\v] doesn’t work consistentlyVampire
06/20/2023, 4:42 PM\v is as little supported in JS as \h.
[^\v] probably means either "not a `v`" or "neither v nor a backslash"Vampire
06/20/2023, 4:47 PMAdam S
06/20/2023, 5:04 PMAdam S
06/20/2023, 5:05 PMAdam S
06/20/2023, 5:06 PMVampire
06/20/2023, 5:12 PMAdam S
06/20/2023, 5:14 PM