随笔分类 -  正则表达式

摘要:要使用正则表达式从字符串中提取<img>标签,您可以使用以下代码: const str = `Some text <img src="image.jpg" alt="Image"> and more text <img src="another.png" alt="Another">`; const 阅读全文
posted @ 2024-03-26 16:10 维维WW 阅读(830) 评论(0) 推荐(0) 编辑
摘要:去掉带左右尖括号的标签 string.replace(/<[^>]+>/g, ""); 去空格 string.replace(/(^\s*)|(\s*$)/g, ''); //去掉首尾空格 string.replace(/\s+/g, ""); //去掉所有空格 string.replace(/(^ 阅读全文
posted @ 2020-05-18 10:58 维维WW 阅读(239) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示