'Remove stuff before this word. Hello!'
How can I remove the text before 'word' in the above string in javascript or jQuery?
Use "substring" combined with "indexOf":
var sample = 'Remove stuff before this word. Hello!';
var substr = sample.substring(sample.indexOf('word')); //substr = 'word. Hello!'
Another alternative:
var str = "Remove stuff before this word. Hello!"
str = str.replace(/.*(?=word)/i, "");
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