Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SyntaxError: Invalid regular expression: missing / [closed]

According to http://www.regexr.com/38o5d my reqex seems to work, but when I implement it into my javascript

var prefix = hash.replace(/\/|#/g, '');

I'll get the following error: SyntaxError: Invalid regular expression: missing /

like image 287
Joshlo Avatar asked Apr 22 '14 13:04

Joshlo


1 Answers

Psychic debugging: Your code isn't in a plain JavaScript or HTML file, but is being printed from a scripting language in which # is a comment character. The #/g, ''); piece is being treated as a comment in your script.

You need to add some quotes to ensure that the whole line gets printed.

like image 139
RichieHindle Avatar answered Oct 19 '22 17:10

RichieHindle