
匹配字符串的开头和结尾
let strTest = "路条编程(www.icoderoad.com)欢迎您!";let testRegex = /^路条编程/;let result = testRegex.test(strTest);console.log( result ) ;// => truestrTest = "您好,路条编程(www.icoderoad.com)欢迎您!";result = testRegex.test(strTest);console.log( result ) ;// => false
let strTest = "路条编程(www.icoderoad.com)欢迎您!";let testRegex = /欢迎您!$/;let result = testRegex.test(strTest);console.log( result ) ;// => truestrTest = "路条编程不仅是在线学习编程的平台,也是学习编程的友好社区!";result = testRegex.test(strTest);console.log( result ) ;// => false
今天就讲到这里,如果有问题需要咨询,大家可以直接留言或扫下方二维码关注公众号。也可以添加 happyzjp 微信受邀加入学习社群,我们会尽力为你解答。



作者:路条编程(转载请获本公众号授权,并注明作者与出处)
文章转载自路条编程,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




