You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

正则表达式拆分段落为句子:特殊场景匹配失效求修正

正则表达式匹配句末时忽略特殊缩写的问题

我编写了一段正则表达式,用于匹配句子结尾,但需要忽略U.S.、U.S.A.、Ser. No.、Pat. No.等特殊场景(这些位置不应作为句末拆分),但运行后未得到正确输出。

我的正则表达式如下:

((?:[A-Z]+\sU\.S\.)|(?:\w\.(\s?\w{1,12}\.)+)|(?:[A-Z]+\s+[A-Z]+\.\s+[A-Z]+)|(?:°\s?[cCfF]\.)|(?:\s+[\(]*[a-h0-9]{1}\))|(?:\.\s*Fig.{1,7}\.)|(?:([.?!;])\s*(?=[\`\’A-Za-z\(])))

示例段落:

This Application is a Continuation of U.S. patent application Ser. No. 15/731,069, filed on Apr. 14, 2017, which was a Continuation of U.S. application Ser. No. 14/998,574, filed on Jan. 21, 2016 which was a Continuation of U.S. application Ser. No. 14/198,695 (now U.S. Pat. No. 9,286,457) filed on Mar. 6, 2014, which was a Continuation in Part of U.S. patent application Ser. No. 12/931,340, filed on Jan. 31, 2011, (now U.S. Pat. No. 8,842,887) which was a Continuation in Part of U.S. patent application Ser. No. 12/627,413 filed on Nov. 30, 2009, (now U.S. Pat. No. 7,916,907) which was a continuation of application Ser. No. 11/151,412, filed on Jun. 14, 2005, now abandoned. application Ser. No. 14/198,695 claims the benefit of Provisional Application No. 61/851,884, filed on Mar. 15, 2013. Application Ser. No. 12/931,340 claims the benefit of Provisional Application No. 61/456,901, filed on Nov. 15, 2010 and application Ser. No. 11/151,412 claims the benefit of Provisional Application No. 60/579,422 filed on Jun. 14, 2004. Testing some more example of U.S.A and U.S in my paragraph. Checking Fig. 3. in my paragraph.

当前正则未达到预期效果,需要调整以正确识别并忽略上述特殊缩写,准确匹配句子的实际结尾。

内容的提问来源于stack exchange,提问作者aakash singh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 02:17:38