javascript - jquery url没有替换
问题描述
我有 jquery 正则表达式,它在顶部找到网址 URL 并将其替换为新的 URL,但是我编写的正则表达式更改了 URL,但正则表达式在末尾添加了 URL 中的其他额外内容。它添加3543463456546456
得很好,而不是https://127.0.0.1/id=12345
<script>
var urlTest = $(location).attr("href");
var test1 = urlTest.replace(/https:\/\/127.0.0.1\/test1\/test2\/(12345)\/3543463456546456/g, "https://127.0.0.1/id=$1");
$(".test").append(document.write(test1));
</script>
不知道为什么它拿起 3543463456546456
解决方案
推荐阅读
- oracle - 如何使复选框已选中为非空且未选中为空
- vb.net - 在 Visual Basic 窗体中单击时隐藏动态创建的按钮
- reactjs - Expo - React Native:Firebase 电话号码身份验证失败
- spring - 为什么在启动 Spring Boot 应用程序之前无法登录?
- reactjs - “vector.project”到相机的标准化屏幕位置?(反应三纤维)
- c++ - 如何在运行时使用模型切换 SQL 数据库
- xamarin.forms - Xamarin Forms - 内容页面中的 webkit
- c - 如何用C语言写日记?
- python - TypeError:导入 sklearn 时需要一个整数(获取类型字节)
- c++ - 如何在 MacOS (OS X) 上将 GNU make 4.3 设为默认