简体   繁体   中英

how to replace " char to '?

我想用'代替" char。

Use the replace method on the string str you want to replace it in:

str = str.replace(/"/g, "'");

Important is to use a regular expression with the g flag set to replace globally. If you omit that g flag or use a string for the search, you will only replace the first occurrence.

str.replace("\"", "\'")

使用替换方法:

str = str.replace(/"/g, "'"));

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