demand background:
A background system of the company. The form page is paged with ajax. After clicking on the page, you want the current url to record the paging information, so that when you refresh the current page, the paging information will not be lost. For example, when I click on page 5 and record a page_num=5, in the current url to refresh the page, I go directly to page 5.
the problem now is that after clicking on paging, I need to update the paging information in url without refreshing and modifying url. Take clicking to go to page 5 as an example.
for example:
https://www.baidu.com/
url:
https://www.baidu.com/?page_num=5
https://www.baidu.com/?page_num=2
url:
https://www.baidu.com/?page_num=5
https://www.baidu.com/?page_num=2&type=test
url:
https://www.baidu.com/?page_num=5&type=test
I now hope to modify the value of page_num specifically through regular expressions, so that the rest of url will not be affected, but this code will not be written (especially regular)? Trouble God to help say the train of thought, it is best to paste some code.
an extension: the above requirement is not just a matter of modifying the page_ value specifically. If there is no page_num information in the url, how to deal with the special case of appending a page_num=5, instead of changing the page_num value? God, if you have time, please take a look at this problem and help write some code. Thank you.