How can I replace underscores with spaces using a regex in Javascript?
var ZZZ = "This_is_my_name";
How can I replace underscores with spaces using a regex in Javascript?
| ||||
feedback
|
If it is a JavaScript code, write this, to have transformed string in
also, you can do it in less efficient, but more funky, way, without using regex:
| |||
feedback
|
Replace "_" with " " The actual implementation depends on your language. In Perl it would be:
But the truth is, if you are replacing a fixed string with something else, you don't need a regular expression, you can use your language/library's basic string replacement algorithms. Another possible Perl solution would be:
| |||
feedback
|
Regular expressions are not a tool to replace texts inside strings but just something that can search for patterns inside strings. You need to provide a context of a programming language to have your solution. I can tell you that the regex For example in Groovy you would do something like:
but this is just language specific ( | ||||
feedback
|
Please refer to this post: | |||
feedback
|
string.replace(/_/, " ")
– Marcel Jackwerth Mar 18 at 18:17:%s/_/ /g
– Felix Kling Mar 18 at 18:17