Reputation: 566
'Remove stuff before this word. Hello!'
How can I remove the text before 'word' in the above string in javascript or jQuery?
Upvotes: 3
Views: 6448
Reputation: 9267
Another alternative:
var str = "Remove stuff before this word. Hello!"
str = str.replace(/.*(?=word)/i, "");
Upvotes: 2
Reputation: 82459
Use "substring" combined with "indexOf":
var sample = 'Remove stuff before this word. Hello!';
var substr = sample.substring(sample.indexOf('word')); //substr = 'word. Hello!'
Upvotes: 8