Check if first letter of word is a capital letter

后端 未结 8 1218
春和景丽
春和景丽 2020-12-07 22:07

Is it possible in Javascript to find out if the first letter of a word is a capital letter?

8条回答
  •  庸人自扰
    2020-12-07 22:39

    Using the match method of the string object prototype:

    const word = 'Someword';
    console.log(word.match(new RegExp(/^[A-Z]/)) !== null);
    

提交回复
热议问题