I want to get rid of all the "."s in JavaScript. What should I do?

Asked 2 years ago, Updated 2 years ago, 37 views

I want to replace . with a space in the string, but I can't.

For example, var mystring = 'okay.this.is.a.string'; If there is, I want to change this to okay this is a string but I used a regular expression mystring.replace(/./g), ') All strings are blank. What's the problem?

javascript string

2022-09-22 12:01

1 Answers

In the regular expression, . is interpreted as any character mystring.replace(/\./g,' ') If you change it like this, it'll work out.


2022-09-22 12:01

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.