A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/javascript/lodash-_-isregexp-method/ below:

Lodash _.isRegExp() Method - GeeksforGeeks

Lodash _.isRegExp() Method

Last Updated : 04 Sep, 2024

Lodash _.isRegExp() method is used to find whether the given value is a regular expression or not. It returns True if the given value is a regular expression. Otherwise, it returns false.  

Syntax:
_.isRegExp(value);
Parameters:   Return Value:

Example 1: In this example, we are passing a regular expression to the lodash _.isRegExp() method. the object starts and ends with ‘/’, therefore it is a regular expression. Hence, the result is true. 

javascript
// Requiring the lodash library  
const _ = require("lodash");

// Use of _.isRegExp() method 
console.log(_.isRegExp(/gfg/)); 

Output:

true

Example 2: In this example, we are passing a string to the _.isRegExp() function Since a string is not a regular expression, the output will be false.  

javascript
// Requiring the lodash library  
const _ = require("lodash");

// Use of _.isRegExp() method 
console.log(_.isRegExp('gfg')); 

Output:

false

Note: This code will not work in normal JavaScript because it requires the library lodash to be installed.



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4