[Regular] does not contain a string of characters

  • /^((?!Hello).)*$/ does not match a string containing hello

Example 1

const 你好吗 = /^((?!你好).)*$/.test('你不好') //true
const 你好吗 = /^((?!你好).)*$/.test('你好') //false

renderings

insert image description here

Example 2

  • need
    1. does not match a string /api/logincontaining/api/register

code

const1 =  /^((?!\/api\/(login|register)).)*$/.test('/api/login') // false
const2 =  /^((?!\/api\/(login|register)).)*$/.test('/api/register') // false

const3 =  /^((?!\/api\/(login|register)).)*$/.test('/api/hello/dfhdf/dfhd?n=1') // true
const4 =  /^((?!\/api\/(login|register)).)*$/.test('/apiapipaip') // true

Guess you like

Origin blog.csdn.net/qq_43614372/article/details/131244434