Board Thread:Code Review/@comment-24757753-20180805110740/@comment-24757753-20180806193821

@Cqm Your parser works well! Just needed a very minor patch:

Taking a closer look at the regex, I've come up with this: ("(?:[^"\n\\]|\\.)+")|\/\/.*|\/\*[\s\S]*?\*\/

The 2nd  and 3rd   alternatives are simple single- and multi-line comment matches - they'll match the same text as current i18n-js will.

Regarding the 1st : Looking at the JSON string form, strings can contain any character but quotes (unescaped), control chars (line break, tab, etc.), and backslashes (when not used for escaping). After opening quote, the regex will match anything but a quote, line break, or backslash, or it will match a backslash plus any character (including quote). It'll do this until the next character is either a quote (end of string) or a line break (a broken string, since JSON doesn't accept control chars in string). This seems to match all the examples at correctly.

Both the regex and the parser seem to do the job, although both will break on JSON containing invalid strings. I wouldn't consider this an issue though, since if the JSON is already bad, it makes no difference if comments can be stripped successfully or not.