展开全部
正则表达式匹配大写字母的表达为/^[A-Z]+$/
其他情况下的匹e69da5e6ba9062616964757a686964616f31333365646263配表达式:
一.测试字符串
varstr='AdobeInDesign、MicrosoftWord等对中文与西文(这里用「西文」来泛指用空格分词的外文)混合排版支持较好的软件,都默认增大汉字和西文的间距。InDesign的默认设置是1/4的全角空格宽度(遵从JIS),也就是约等于一个半角空格。
匹配单个字母/数字
varreg=/[0-9a-z]/;
console.log(str.match(reg));//结果:["d"]
二、由一可以看出并没有匹配到大写字母
varreg=/[0-9a-z]/i;
console.log(str.match(reg));//结果:["A"]
3.前面都是匹配单一字符,那么要匹配所有字母和数字呢?
varreg=/[0-9a-z]/gi;
console.log(str.match(reg));//结果:["A","d","o","b","e","I","n","D","e","s","i","g","n","M","i","c","r","o","s","o","f","t","W","o","r","d","I","n","D","e","s","i","g","n","1","4","J","I","S"]
4.如果不要单个字符,要完整单词匹配或字母数字组合呢?
varreg=/[0-9a-z]+/gi;
console.log(str.match(reg));//结果:["Adobe","InDesign","Microsoft","Word","InDesign","1","4","JIS"]