1.利用正则提取URL后面的请求页数

<html>
<head>
<title></title>
<script type="text/javascript">
window.onload=function(){
var urlStr='https://www.baidu.com/s?pIndex='+45;
var rec=/=(.+)/.exec(urlStr)[1];
alert(rec);
}
</script>
</head>
<body>

</body>
</html>

运行后弹出的是45。

 有关更多正则学习,请详见:http://www.cnblogs.com/jamesping/articles/2252675.html#undefined

2.利用正则限制输入框只能输入数字

<input type="text" onkeyup="this.value=this.value.replace(/[^\d]/g,'') "/>

  

相关文章:

  • 2022-02-16
  • 2021-09-22
  • 2021-07-07
  • 2021-11-26
  • 2021-11-08
  • 2021-11-18
  • 2021-08-19
  • 2021-12-16
猜你喜欢
  • 2022-02-22
  • 2022-12-23
  • 2021-11-27
  • 2021-08-16
  • 2021-08-10
  • 2021-12-26
  • 2021-09-11
相关资源
相似解决方案