Returns true if object is a RegExp (official Underscore docs). Literals like /moe/ and new RegExp("moe") pass; strings and other types do not. Stable helper — not deprecated.
Pass the required arguments shown below. Underscore object helpers usually return a new value — check whether the source object is mutated.
Syntax
Call _.isRegExp. Start with this line.
Underscore
_.isRegExp(object)
Call
What it does
_.isRegExp(object)
Primary signature.
_.isRegExp(...)
Call with the arguments your case needs.
Load Underscore with import _ from "underscore" (or the UMD CDN build) so these helpers are available as _.
Branch. If pattern is already a RegExp, use it as-is.
Coerce. Otherwise wrap the string with new RegExp(pattern).
Test..test(value) returns whether the text matches.
Pattern. Type-check first — then call regex methods.
Compatibility
Browser & Runtime Support
_.isRegExp ships with Underscore.js (1.x). It runs anywhere Underscore runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install underscore.
✓ Stable · Underscore 1.x
_.isRegExp()
Available in [email protected] (UMD / ESM). Works in evergreen browsers and current Node LTS when Underscore is loaded.
100%With Underscore 1.x
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
_.isRegExpUnderscore 1.x+
Bottom line: Safe for production once Underscore is on the page or in your bundle. Not a native browser API — load Underscore first. Prefer a pinned CDN version (e.g. [email protected]).
Frequently Asked Questions
_.isRegExp(object) returns true only when the value is a RegExp — a literal such as /moe/ or new RegExp("moe"). Strings, functions, numbers, and plain objects return false.
_.isRegExp(/moe/) returns true. The docs use a real RegExp literal on purpose — that is the type the helper looks for.
No. "/moe/" or "moe" is still a string. Build a RegExp with a literal or new RegExp(...) first, then call isRegExp on the result.
typeof /a/ is "object", so typeof is too broad. Underscore checks the internal [object RegExp] tag and returns true only for real RegExp values.
Use it as a guard before calling .test() or .exec(), or when an API may accept either a string or a RegExp and you need to branch safely.
No. It is a stable Underscore type helper. Load Underscore 1.x (CDN or npm) and call _.isRegExp(value).