梗概

示例

  • /(.(?!png)*?)/不能匹配(测试)pngtest
  • 以下是一个示例,假设要匹配不包含“apple”这个字串的字符串:
const regex = /^(?!.*apple).*$/;
const str1 = "banana is good";
const str2 = "I have an apple";
console.log(regex.test(str1)); // true
console.log(regex.test(str2)); // false
  • 如果是不能开头是apple的:/^(?!^apple).*$/