This regex pattern matches strings that contain only letters (both uppercase and lowercase) and spaces. ^ asserts the start of the string, [a-zA-Z] matches any letter, \s matches any whitespace character (in this case, space), + allows for one or more occurrences of the previous characters, and $ asserts the end of the string.
const regex = /^[a-zA-Z\s]+/;
const str = 'Hello World';
console.log(regex.test(str)); // Output: true
Copier