js replace 如何替换字符串中的最后一个匹配项
2024-08-22 23:44:53
1.正则表达时,贪婪模式,.*会一直匹配到最后一个
// 验证
let str = "123【空】345【空】789【空】0";
let res = str.replace(/(.*)【空】/,'$1测试');
console.log(res); // 123【空】345【空】789测试0
.
最新文章
- 苹果下如果安装nginx,给nginx安装markdown第三方插件
- URL 学习总结
- javascript url 相关函数(escape/encodeURL/encodeURIComponent区别)
- Redis必要的一些配置
- sql server查询时候注意的基本优化常识
- SharedPreferences的工具类,使用起来方便、快捷
- Visual Studio Code使用typings拓展自动补全功能
- Laravel Eloquent ORM
- Python中的循环与跳出
- 解析:type t_string is table of varchar2(32767) index by binary_integer
- (转)go rabbitmq实践
- golang http.client 遇到了 Connection reset by peer 问题
- Bootstrap -- 表格样式、表单布局
- hnsdfz -- 6.20 -- day5
- composer阿里云短信服务不支持传参为数值--为2017年短信接口,2018阿里云有更新http://www.cnblogs.com/q1104460935/p/8916096.html
- IE6浏览器的bug问题及相关解决的方法
- python之路——模块和包
- Hadoop视频教程汇总
- Logcat用法初探
- web操作文件的上传到服务器 并可下载 并且读取出来
热门文章
- ubuntu 自动获取ip
- C++反汇编-虚函数
- tomcat部署应用仅需ip和port访问
- 关于myBatis的问题There is no getter for property named 'USER_NAME' in 'class com.bky.model.实例类'
- WINDOWS 线程 纤程 进程
- MVC之Ajax如影随行
- java跨域解决
- andriod 错误:Only the original thread that created a view hierarchy can touch its views——Handler的使用
- Android读取Excel文件
- opencv编译Python接口