Regular Expression To Match Morse Code

A regular expression to match Morse Code.

/^[.-]{1,5}(?:[ \t]+[.-]{1,5})*(?:[ \t]+[.-]{1,5}(?:[ \t]+[.-]{1,5})*)*$/

Matches:

  • .-.
  • — —
  • — — .-.

Non-matches:

  • ===.===
  • −·−·