Lodash.js – isRegExp() function
A simple Lodash.js example of the isRegExp() function, which checks if the variable is a regular expression.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta name="description" content="Tizen example"/>
<title>Tizen lodash.js example</title>
<script src="js/lodash.min.js"></script>
</head>
<body>
<div id="first">
</div>
<br>
<div id="second">
</div>
<script>
var firstDiv = document.getElementById('first');
var secondDiv = document.getElementById('second');
var firstValue = /^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z][a-z])|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i;
firstDiv.innerHTML = "Having a string with an e-mail verification regular expression:<br><br>";
firstDiv.innerHTML += firstValue;
var result = _.isRegExp(firstValue);
secondDiv.innerHTML = "...we will check if the provided value is really a regular expression... and we get:<br><br>";
secondDiv.innerHTML += result;
</script>
</body>
</html>