[javascript] Matching a Forward Slash with a regex

I don't have much experience with JavaScript but i'm trying to create a tag system which, instead of using @ or #, would use /.

var start = /#/ig; // @ Match

var word = /#(\w+)/ig; //@abc Match

How could I use a / instead of the #. I've tried doing var slash = '/' and adding + slash +, but that failed.

This question is related to javascript regex

The answer is


You can escape it like this.

/\//ig; //  Matches /

or just use indexOf

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

Similar questions with javascript tag:

Similar questions with regex tag: