Reputation: 7569
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 ?
Upvotes: 5
Views: 92
Reputation: 46738
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:
/\*(.+)?/
Upvotes: 5
Reputation: 982
You could just add an expression to the start that doesn't make a difference:
/.{0,}*(.+)?/
Upvotes: 0