Skip to content
Advertisement

Tag: preg-replace

Javascript regex get only page number from URL

i have URL like https://example.com/my-list/page/35/?a=45&b=56 I want to get page number using regex that is after /page/ in url, the result i want is 35 Answer There’s 2 easy ways you could do it using RegEx: The first way: The second way: You can also split the string, and then use regex to grab just the beginning of the string:

Advertisement