Finding uppercase characters within a string

前端 未结 3 1065
北海茫月
北海茫月 2020-12-03 21:26

I am trying to write a function that decryptes an encrypted message that has uppercase letters (showing its a new word) and lower case characters (which is the word itself).

3条回答
  •  离开以前
    2020-12-03 21:40

    I'm not too sure I follow, but you can strip using the replace method and regular expressions

    var str = 'MaEfSdsfSsdfsAdfssdGsdfEsdf';
    var newmsg = str.replace(/[a-z]/g, '');
    var old = str.replace(/[A-Z]/g, '');
    

    In this case, newmsg = 'MESSAGE'.

提交回复
热议问题