How to replace character inside a string in JavaScript
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
total answers (1)
Use the JavaScript
replace()
methodYou can use the JavaScript
need an explanation for this answer? contact us directly to get an explanation for this answerreplace()
method to replace the occurrence of any character in a string. However, thereplace()
will only replace the first occurrence of the specified character. To replace all the occurrence you can use the global (g
) modifier. The following example will show you how to replace all underscore (_
) character in a string with hyphen (-
).