1. is-regex
Is this value a JS regex? Works cross-realm/iframe, and despite ES6 @@toStringTag
is-regex
Package: is-regex
Created by: inspect-js
Last modified: Fri, 09 Jun 2023 21:33:14 GMT
Version: 1.1.4
License: MIT
Downloads: 131,682,988
Repository: https://github.com/inspect-js/is-regex

Install

npm install is-regex
yarn add is-regex

is-regex Version Badge

github actions
coverage
dependency status
dev dependency status
License
Downloads

npm badge

Is this value a JS regex?
This module works cross-realm/iframe, and despite ES6 @@toStringTag.

Example

 var isRegex = require('is-regex');
var assert = require('assert');

assert.notOk(isRegex(undefined));
assert.notOk(isRegex(null));
assert.notOk(isRegex(false));
assert.notOk(isRegex(true));
assert.notOk(isRegex(42));
assert.notOk(isRegex('foo'));
assert.notOk(isRegex(function () {}));
assert.notOk(isRegex([]));
assert.notOk(isRegex({}));

assert.ok(isRegex(/a/g));
assert.ok(isRegex(new RegExp('a', 'g')));

Tests

Simply clone the repo, npm install, and run npm test

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin