我正在尝试删除 URL 的最后一个目录部分。我的网址如下所示:
https://my_ip_address:port/site.php?path=/path/to/my/folder.
单击按钮时,我想将其更改为
https://my_ip_address:port/site.php?path=/path/to/my. (删除最后一部分)。
我已经尝试过了window.location.replace(/\/[A-Za-z0-9%]+$/, ""),结果是
https://my_ip_address:port/undefined.
我应该使用什么正则表达式来做到这一点?