abc.png 要求匹配成功 //abc.png 要求匹配失败 http://a.com/abc.png 要求匹配失败 https://a.com/abc.png 要求匹配失败 请问符合以上4种情况的正则怎么写?
const reg = /^(?!(\/|http)).*$/; const arr = [ 'abc.png', '//abc.png', 'http://a.com,/abc.png', 'https://a.com/abc.png' ]; const result = arr.map(item => reg.test(item)); 这样试试
这样试试