score:0

Accepted answer

if the 2 words only use the alphabets without any special characters.

you can use the simplest one. /^([a-z]+)\s+([a-z]+)(\s*)$/gi

 [a-z]+ tells any character in the alphabet with quantifier of one or more
 \s* -> is a space with a quantifier of zero or more
  i -> on the last part tells case-insensitive matching

let a = 'my word';
let b = 'oneword';
let c = 'using three words';
let d = 'onewordwithspace ';
let e = 'my wordwithspace ';

let regex = /^([a-z]+)\s+([a-z]+)(\s*)$/gi;

console.log((regex.test(a))); // true
console.log((regex.test(b))); // false
console.log((regex.test(c))); // false
console.log((regex.test(d))); // false
console.log((regex.test(e))); // true

score:1

you can try this :

([a-za-z]+)\s([a-za-z]+)$

Related Query

More Query from same tag