MMT designer MMT designer - 3 months ago 17x
PHP Question

replace page number using Regular Expression in Javascript

I have a URL as Follow:

I need to replace any number that comes at the end of URL which represents page number.
If possible which I think it is, I want to use regular expression in case the domain changes, the code still works.

I am also using PHP ...

Could help me with a proper RegEx?


Find The Answer:

string.replace(/\/page\/[0-9]+/, '/page/' + pageNum);

pageNum can be any variable to replace the page number