[英]issue to detect first matching end of string with regex
我試圖找到以“start”開頭並以以下字符串之一結尾的字符串:(, |. | finish) 后跟“not”或“here”時跳過“finish”。
這是示例:
CONF: For this charaxter start 6 years of this Revision 01 its indicated in the house warranty not finish for received days completion. affected you. of your face
為此,我使用了以下正則表達式:
(start|START).*(?!not finish|here)(?=[.]|[,]|finish)
我的嘗試鏈接: https://regex101.com/r/USaH6I/1
要求的回報是:
start 6 years of this Revision 01 its indicated in the house warranty not finish for received days completion
但我得到了:
start 6 years of this Revision 01 its indicated in the house warranty not finish for received days completion, affected you
如果您的意思是在“完成”之后找到“這里”或“不”時跳過匹配,請嘗試以下操作:( (?:start|START).*?(?=[.]|[,]|(finish (?!here|not)))
在這里測試: https://regex101.com/r/PaXBKL/1
如果你的意思是如果在 'finish' 之前找到 'here' 或 'not' 則跳過匹配,那么試試這個: (?:start|START).*?(?=[.]|[,]|((?<!here|not) finish))
這些遵循您停止時或時的條件。 被發現。
案例:
當首先找到“完成”時:
CONF:對於此版本 01 的此字符開始 6 年,其在房屋保修中表示在收到的天數內未完成,在此完成。 影響了你。 你的臉
當“完成”后跟“此處”/“不”時,它將跳到 a ,
or .
發現:
CONF:對於此字符,此版本 01 開始 6 年,其在房屋保修中注明不是收到的天數,在這里完成。 影響了你。 你的臉
CONF:對於此版本 01 的 6 年開始的這個角色,其在房屋保修完成時表示不是,收到天數在這里完成。 影響了你。 你的臉
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.