JavaScript Regular Expression Error: “Declaration or Statement Expected” [closed]

I’m trying to create a JavaScript function to validate timestamps in a specific format. I have the following function:

function isTimestamp(line) {
  return /^[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3} --> [0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3}$/.test(line);
}

However, I’m encountering an error after the part ^[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3} –> [0-9]. The error message is: “‘ expected”. Then, after “:[0-9]”, I get the error: “Declaration or statement expected.javascript”.

I’ve double-checked the regular expression syntax and can’t find any obvious mistakes. Can someone please help me identify the issue and provide a corrected version of the function?

here the whole project https://github.com/quadroce/avocado

This is a project about a convertor of .vtt file, it fixes uppercases and lowercases, it fixes the length of the strings