如何匹配js中的单行注释?
我有一段字符串
var str = `
//test 1
console.log('123'); //test 2
console.log('http://a.com')`;
str.match(/\/\/[^\n]*/g);
想匹配出//test 1 //test 2这种注释,而且排除掉http://a.com,该如何写正则呢
如何匹配js中的单行注释?
我有一段字符串
var str = `
//test 1
console.log('123'); //test 2
console.log('http://a.com')`;
str.match(/\/\/[^\n]*/g);
想匹配出//test 1 //test 2这种注释,而且排除掉http://a.com,该如何写正则呢
13 回答12.8k 阅读
7 回答1.9k 阅读
3 回答1.1k 阅读✓ 已解决
2 回答1.2k 阅读✓ 已解决
6 回答852 阅读✓ 已解决
6 回答1k 阅读
2 回答1.3k 阅读✓ 已解决