使用 Typescript 正则表达式匹配并获得 MO 这一行冒号后的内容,并将其保存为 string 类型。 可以使用正则表达式来匹配并获得 MO 这一行冒号后的内容,然后将其保存为 string 类型。以下是使用 Typescript 实现的代码示例:

const text = `*** Date: 2023\/02\/15 14:37:18 ***\t\t
Handler Version: HT3310K v1.15f\t\t
MO: 3823318.01-MTK1-1\t\t
LOT Number: 3823318.01-MTK1\t\t
Program Name: 1122092-95GUKNAN-SR\t\t
Test Plan: SPTEST\t\t\t\t
Operator ID UU51-1\t\t\t\t
Enable Port\t: 0 \/ 0.0%\t\t
Start Time\t: 99_12_30 00:00:00\t\t
End Time\t: 99_12_30 00:00:00\t\t
IC Count\t: Input\t768\tTested\t0\tOutput\t768`;

const regex = /MO:\s*(.+)/;
const match = text.match(regex);

if (match && match.length > 1) {
  const moValue = match[1];
  console.log(moValue);
} else {
  console.log("MO value not found");
}

运行以上代码,将会输出:

3823318.01-MTK1-1

这是从输入文本中提取的 MO 行后的内容。

使用 Typescript 正则表达式提取文本中的 MO 值

原文地址: https://www.cveoy.top/t/topic/p0DJ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录