There is a text, let's say:
Съешь же ещё этих мягких |Какая-то фраза| французских булок, да выпей чаю How to pull out with JS |Какая-то фраза| knowing only that it will be between soft and french ?
There is a text, let's say:
Съешь же ещё этих мягких |Какая-то фраза| французских булок, да выпей чаю How to pull out with JS |Какая-то фраза| knowing only that it will be between soft and french ?
You can use the String.prototype.match method:
var str = "Съешь же ещё этих мягких |Какая-то фраза| французских булок, да выпей чаю"; var regExp = /мягких\s+(.*)\s+французских/; var result = str.match(regExp)[1]; console.log(result); Or using the RegExp.prototype.exec method:
var str = "Съешь же ещё этих мягких |Какая-то фраза| французских булок, да выпей чаю"; var regExp = /мягких\s+(.*)\s+французских/; var result = regExp.exec(str)[1]; console.log(result); Source: https://ru.stackoverflow.com/questions/865190/
All Articles