我在变量中存储了特定的字符串。不过我只需要<4854D382GA9@example.com>
.
示例字符串:
X-PHP-Originating-Script: 0:acr.php
x: <193@example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII;
Format=flowed
Text-ID: <4854D382GA9@example.com>
Date: Sun, 02 Jul 2017 12:22:12 +0500
如何使用 javascript 实现此目的?
感谢任何帮助。谢谢
最佳答案
var str = `X-PHP-Originating-Script: 0:acr.php
x: <193@example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII;
Format=flowed
Text-ID: <4854D382GA9@example.com>
Date: Sun, 02 Jul 2017 12:22:12 +0500`;
var matches = str.match(/Text-ID:\s(.+)/);
console.log(matches[1]);
关于javascript - 使用 javascript 从字符串中提取特定文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45450352/