从特定单词开始提取字符串并以一年结束的弦
输入1:字符串是封闭的。
输出1:上诉(民事)2007年648
输入2:弦是封闭式案例号:上诉(民事)6408 2007年之间。
输出2:上诉(民事)2007年6408
我想提取以案例号(案例不敏感)的字符串,结束,这是一个数字的第二次出现。
我尝试了以下代码。
case_no = re.search(r'(?=Case No)(\w+\W+)*?\b\d{4}\b', contents, re.IGNORECASE)
if case_no:
print(case_no.group(0))
INPUT 1: The string is enclosed CASE NO.: Appeal (civil) 648 of 2007 in between.
OUTPUT 1: Appeal (civil) 648 of 2007
INPUT 2: The string is enclosed CASE NO.: Appeal (civil) 6408 of 2007 in between.
OUTPUT 2: Appeal (civil) 6408 of 2007
I want to extract the string starting with the word CASE NO.(Case Insensitive) and ending with the year being the second occurrence of a number.
I have tried the following code.
case_no = re.search(r'(?=Case No)(\w+\W+)*?\b\d{4}\b', contents, re.IGNORECASE)
if case_no:
print(case_no.group(0))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我将在此处使用一个懒点来匹配
案例之后的最近一年:
:I would use a lazy dot here to match the nearest year occurring after
CASE NO.
: