如何在比赛第一次发生时停止? [英] How to stop at first occurence of match?
问题描述
我在这里有这个样本:
received date
something
something
26/6/2013
.
.
due date
something
27/6/2013
我只想获取第一次出现的接收日期".我正在尝试使用我拥有的这个正则表达式:
I want to get just the first occurence of Received Date. I am trying to use this regular expression I have:
(?is)(?<=(invoice)?(?<!due.*?)date.*?)(\d{1,4}/\d{1,4}/\d{1,4})
我想要做的是获取在其之前是否有接收日期的日期,但要避免获取到期日期前缀.我只想获取2013年6月26日的信息..可能也可以像这样工作:
What I want to do is to get the date that either has a received preceding it or not, but to avoid getting if there is a prefix of due. I just want to get the 26/6/2013 .. also possibly, it would work the same with something like this:
date
something
something
26/6/2013
.
.
due date
something
27/6/2013
我是regex的新手,我花了很多时间尝试各种不同的组合,但似乎都不起作用!
I am new to regex, and I spent a lot of time trying out different combinations but none seemed to work!
请帮助谢谢!
我正在使用Expresso.
I am using Expresso..
这是我从上面获得的输出:
Here is the output I am getting from the above:
26/6/2013
27/6/2013
再次,我只想要第一个.
Again, I only want to get the first one..
推荐答案
问题可以简化为:获取第一个日期.
The problem can be simplified to: Get the first date.
(?s)(\d{1,2}/\d{1,2}/\d{2,4}).*
这篇关于如何在比赛第一次发生时停止?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!