RegExp patterns validator … check if the inputed regex is valid
import { is_regex } from 'https://deno.land/x/is_regex@v1.0.0/mod.ts'
or from nest.land
packages
import { is_regex } from 'https://x.nest.land/is_regex@v1.0.0/mod.ts'
Pass the string of user agent from request headers as argument
// from RegExp line
console.log(isRegEx(/moncef/g)) //=> true
// from RegExp object
console.log(isRegEx(new RegExp('moncef', 'g'))) //=> true
// from string
console.log(isRegEx('/moncef/g')) //=> true
// from RegExp line
console.log(isRegEx(123)) //=> false
// from RegExp object
console.log(isRegEx(null)) //=> false
// from string
console.log(isRegEx({})) //=> false
deno run https://deno.land/x/is_regex@v1.0.0/test.ts
Here
Author: moncefplastin07
Source Code: https://github.com/moncefplastin07/deno-is-regex
#deno #node #nodejs #javascript