I have a string like below
var str = "Lorem Ipsum is simply& dummy text of the &printing and & typesetting industry."
How can I remove the second character & and everything after it in jQuery?
You can combine split and join:
str.split("&", 2).join("&")
The argument 2 will make that split only returns the first two substrings that are split off, the rest is ignored. join would put those 2 pieces back together with the restored &.
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