我对javascript还是很陌生,我找不到一个指南来检查字符串格式(除了完整的代码如何检查电子邮件等)。
因此,我需要检查我的变量是否采用这种格式-applicationcode0001。文字不会改变-像这样的东西-variable=="applicationcode"+[number]+[number]+[number]+[number]
如果您可以提供一些链接来检查像这样的字符串变量,我将非常高兴。
谢谢,MJ
var myRe = /^applicationcode\d{4}$/;
console.log(myRe.test('applicationcode0001'));
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句