I have a string of data..
This is a template body for <<Approved>> <<Submitted>>
I want to replace "<" with "<<" and ">" with ">>"
To replace "<" I wrote this code..
var body = $('#txtHSliderl').val().replace("<", "<<");
But it only seems to replace the first occurrence..
This is a template body for <<<Approved>> <<Submitted>>
How do I replace all occurrences?
var body = $('#txtHSliderl').val().replace(/</g, "<<");
You need to use a regular expression, so that you can specify the global (g) flag:
var body = $('#txtHSliderl').val().replace(/</g, "<<");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With