I am getting this error `SyntaxError` when I enabl...
# multiplatform
j
I am getting this error
SyntaxError
when I enable js in a project that only has common code. I think it is related to use regex in the lib, anyone know what can be happening?
Copy code
SyntaxError: Invalid regular expression: /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-(?!(?i)SNAPSHOT\.\d)([a-zA-Z]+(\.\d+)|\b(?i)SNAPSHOT\b)?)?$/: Invalid group
m
Looks like the JS regex are slightly different from the JVM regexes 😕
Looks like you have sub-groups like
(()())
?
Is that even a thing?
Non capturing groups?
j
not sure tbh, I am not an expert in regex, I just know it is working because I have tests for all cases, working ones and other ones that throw exceptions
I think the problem is
(?i)
, but if I remove it, tests fails in JVM
IMO should be great stdlib just transform the regex to be compatible with js
m
Yea I agree but that might be super complex
And possibly slower
Looks like JS requires angle brackets column for non capturing groups: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Groups_and_Ranges
Maybe try
(?:i)
j
it breaks java one I think
yep
I don't know if it is possible without an expect/actual
the one you shared is a valid js regex, but it doesn't the same I have
toRegex allow receiving a parameter to ignore case, it seems it works
at least on jvm
😮 1
it is working on my case but because I can ignore case in the whole string, if I need only an specific part to be ignored, then I would need
(?i)
, so probably I have to recheck again this problem in the future 😞