如果可以的话,解决这个问题. [英] solve this if u can.

查看:59
本文介绍了如果可以的话,解决这个问题.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<script type="text/javascript">
var str = "abc";
var patt1 = /^[a-z]$/;
if(patt1.test(str))
{
document.write(str);
alert(str);
}
</script>

i want to make regular expression for string if it match then alert
what problem in this code?

推荐答案

/; if(patt1.test(str)) { document.write(str); 警报(str); } < /script > 我想对字符串进行正则表达式匹配,然后发出警报 这段代码有什么问题?
/; if(patt1.test(str)) { document.write(str); alert(str); } </script> i want to make regular expression for string if it match then alert what problem in this code?


它只匹配"a"到"z"范围内的单个字符-我怀疑您需要:
It only matches a single character in the range ''a'' to ''z'' - I suspect you need:
^[a-z]*


代替


这篇关于如果可以的话,解决这个问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆