Helllo, ajax request returs me a string, that I store in a variable:
text = "bla bla bla word1 unknown. Word2 bla bla bla";
I know the every word in the text except the 'unknown'. I need to store the 'unknown' word in a variable to do further work. I know that it can be done by Regex, but I don't quite understand it. Can someone show me the trick? Thank you for your time!
You can use a simple .match like this.
text = "bla bla bla word1 word i want Word2 bla bla bla";
myWord = text.match("word1(.*)Word2")[1];
console.log(myWord);
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