How can I remove the semicolon (;) from a string by using JavaScript?
For example:
var str = '<div id="confirmMsg" style="margin-top: -5px;">'
How can I remove the semicolon from str?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use the
replacemethod of the string object. Here is what W3Schools says about it: JavaScript replace().In your case you could do something like the following:
You can also use a regular expression:
This will replace all semicolons globally. If you wish to replace just the first instance you would remove the
gfrom the first parameter.