var str = "I'm a very^ montréal Str!ng.";
我如何用Ima-very-montreal-Strng
替换它
I suppose you need split()
and join()
functions. For the string you have given, the code should be:
str = str.split(' ').join('-');
str = str.split('é').join('e');
str = str.split('!').join('i');
str = str.split('^').join('');
str = str.split("'").join('-');
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.