Matching a Forward Slash with a regex

You can escape it like this.

/\//ig; //  Matches /

or just use indexOf

if(str.indexOf("/") > -1)

You need to escape the / with a \.

/\//ig // matches /

If you want to use / you need to escape it with a \

var word = /\/(\w+)/ig;

You can escape it by preceding it with a \ (making it \/), or you could use new RegExp('/') to avoid escaping the regex.

See example in JSFiddle.

'/'.match(/\//)            // matches /
'/'.match(new RegExp('/')  // matches /