Regular Expression That Matches RegExps

  • : Function split() is deprecated in /home/kourge/kourge.net/modules/filter/filter.module on line 895.
  • : Function split() is deprecated in /home/kourge/kourge.net/modules/filter/filter.module on line 895.

Being bored, curious, and redundant all at the same time, I thought: "What if you want to check, in JavaScript, to see if a string is a JavaScript regular expression?" The obvious answer is, in a sense, self-referencing, because you'll have to check with regular expressions too. So basically, a regular expression to check regular expressions in JavaScript. Ugh.

/^\/.*\/[img]*$/

The flags i, m, and g are the possible RegExp flags, although they give a false impression of HTML <img> tags.