我在网上搜索了一种方法来做到这一点,到目前为止我只遇到了一些并不真正符合我正在寻找的标准的例子......
我想提取出现在“received from:”和“The information Transmission”之间的字符串
通常该字符串将显示为:
2014-01-23 13:26:13 - Jim Superman received from: JIM.superman@superheroes.com
please bla bla bla, we need a new super hero in the complex
supermanager of managers test bla bla [wawa]
The information transmitted
最佳答案
听起来像一个简单的子字符串:
var str = ...; // Where ever it came from
str = str.substring(
str.indexOf("received from:") + "received from:".length,
str.lastIndexOf("The information transmitted"));
console.log(str); // Check the results
请注意如何将长度添加到“接收自:”。这样,文本“received from:”就不会包含在您的输出中。
关于javascript - 在javascript中提取由两个不同短语分隔的大字符串内部的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21318341/