简体   繁体   中英

RegEx line shows warning in jsHint

I haave the following line in my code :

invitationMessage = invitationMessage.replace(/{{from}}/g, from);

when i do jsLint on the code, it shows the following warning

unescaped {

what is the correct way to write this statement? What is wrong with this statement?

Escape the value { and } :

invitationMessage = invitationMessage.replace(/\{\{from\}\}/g, from);

Because these are RegExp symbols which can be used like:

\*{1, 3}

It matches * or ** or *** . An asterisk with a length between 1 and 3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM