随笔分类 - 正则表达式
摘要:要使用正则表达式从字符串中提取<img>标签,您可以使用以下代码: const str = `Some text <img src="image.jpg" alt="Image"> and more text <img src="another.png" alt="Another">`; const
阅读全文
摘要:去掉带左右尖括号的标签 string.replace(/<[^>]+>/g, ""); 去空格 string.replace(/(^\s*)|(\s*$)/g, ''); //去掉首尾空格 string.replace(/\s+/g, ""); //去掉所有空格 string.replace(/(^
阅读全文