JS regular conflicts with comments

Recently when writing a front-end components, stumbled a little conflict between regular and comments, now share with you.

Just below is the code for a regular expression:

str = 'hello js fan';
console.log(str.match(/s.*/));

FIG results are as follows:
JS regular conflicts with comments

I added the following comments:

/*this is a test
str = 'hello js fan';
console.log(str.match(/s.*/));
*/

On the surface this code is normal, but after it run?

This is the result of running
JS regular conflicts with comments
display behind the first three should not take ')'.

Guess it should be no regular use quotation marks, resulting in the regular inside "* /" In order to make a comment at the end when JS resolution.

They note that when using a regular piece, accidentally fall into the trap!

I little friends, I do not know has to say about it?

Guess you like

Origin blog.51cto.com/14640983/2458369