In JavaScript, a regular expression is written in the form of /pattern/modifiers where "pattern" is the regular expression itself, and "modifiers" are a series of characters indicating various options. The "modifiers" part is optional.
* /g enables "global" matching. When using the replace() method, specify this modifier to replace all matches, rather than only the first one.
* /i makes the regex match case insensitive.
* /m enables "multi-line mode". In this mode, the caret and dollar match before and after newlines in the subject string.
You can combine multiple modifiers by stringing them together as in /regex/gim.
Since forward slashes delimit the regular expression, any forward slashes that appear in the regex need to be escaped. For example, the regex 1/2 is written as /1\/2/ in JavaScript.
As with anything, you can find much more information about JavaScript on the web if you Google or Bing it.