Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regex - Use /* in JS without getting my code in comment

I need to do some split, like this:

$(element).split(/*(.+)?/)[1]);

But those /* characters, make my code be as a comment. How can I use it & avoid from this to happen ?

like image 814
ParPar Avatar asked Nov 15 '12 16:11

ParPar


1 Answers

Escape the * character to match it literally. It means something within a regex. It means the previous token is matched 0 or more times.

/\*

The regex should be:

/\*(.+)?/
like image 76
Anirudh Ramanathan Avatar answered Sep 23 '22 04:09

Anirudh Ramanathan