If they need capital:
const startsWithCapitals = /^[A-Z]{4}/.test(string);
Or, if they just need to be letters, add ifor the case of ignoring:
const startsWithLetters = /^[a-z]{4}/i.test(string);
^means the beginning of the line, and {number}means x copies
source
share