I'm guessing that your intent was to escape the -
characters. But that's not necessary (and is incorrect). If your intent was to match just dashes, you should remove those backslashes entirely:
let pattern = "^(0[0-9]{2,3}-)?([2-9][0-9]{6,7})+(-[0-9]{1,4})?$"
Unrelated, but I'm suspicious of that +
character. Did you really mean that you wanted to match one or more occurrences of [2-9][0-9]{6,7}
? Or did you want to match exactly one occurrence?