Hello I have a URL string:
'http://www.hello.com/index.php?page=11'
What is the regular expression that I have to execute to get the page number?
Hello I have a URL string:
'http://www.hello.com/index.php?page=11'
What is the regular expression that I have to execute to get the page number?
Use capturing group to capture one or more digits which are present just after to ?page=
.
> 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