以下是使用 TypeScript 编写的代码,用于从给定文本中匹配并提取 MO 行冒号后的内容:\n\ntypescript\nconst text = `*** Date: 2023\/02\/15 14:37:18 ***\nHandler Version: HT3310K v1.15f\nMO: 3823318.01-MTK1-1\nLOT Number: 3823318.01-MTK1\nProgram Name: 1122092-95GUKNAN-SR\nTest Plan: SPTEST\nOperator ID UU51-1\nEnable Port : 0 \/ 0.0%\nStart Time : 99_12_30 00:00:00\nEnd Time : 99_12_30 00:00:00\nIC Count : Input 768 Tested 0 Output 768`;\n\nconst regex = /MO:\s*([^\s]+)/;\nconst match = text.match(regex);\n\nlet moValue: string | null = null;\nif (match && match[1]) {\n moValue = match[1];\n}\n\nconsole.log(moValue);\n\n\n输出结果将是:3823318.01-MTK1-1


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

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