Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Regex如何从url字符串获取参数。Jascript_Javascript_Jquery_Html_Regex - Fatal编程技术网

Javascript Regex如何从url字符串获取参数。Jascript

Javascript Regex如何从url字符串获取参数。Jascript,javascript,jquery,html,regex,Javascript,Jquery,Html,Regex,你好,我有一个URL字符串: 'http://www.hello.com/index.php?page=11' 我必须执行什么正则表达式才能获得页码 (\d+)[^\d]*$ 试试这个。抓拍。看演示 用于捕获一个或多个数字,这些数字正好出现在to?page= 您可以不使用任何regexp'http://www.hello.com/index.php?page=11“.split'page=”[1]没错!非常感谢。如果页面后面还有其他参数呢?不,没有。如果页面后面的参数包含数字,这也不起作用。

你好,我有一个URL字符串:

'http://www.hello.com/index.php?page=11'
我必须执行什么正则表达式才能获得页码

(\d+)[^\d]*$
试试这个。抓拍。看演示

用于捕获一个或多个数字,这些数字正好出现在to?page=


您可以不使用任何regexp'http://www.hello.com/index.php?page=11“.split'page=”[1]没错!非常感谢。如果页面后面还有其他参数呢?不,没有。如果页面后面的参数包含数字,这也不起作用。
> var s = 'http://www.hello.com/index.php?page=11'
undefined
> var re = /\?page=(\d+)/;
undefined
> console.log(re.exec(s)[1])
11
> var re = /\bpage=(\d+)/;
undefined
> console.log(re.exec(s)[1])
11