如何搭配培根的一句話和肉的2個或少於2個字的距離?正則表達式匹配指定單詞的句子在指定距離
Bacon is thinly sliced lean pork meat ----Reject
Bacon is pork meat ----Match
我曾嘗試:
^(\bBacon\b)(\040){1,2}(\bmeat\b)$ => i try to match with the "space" between but it's not working
^(?=.*?\bBacon\b)(?=.*?\bmeat\b).*$ => this will match everything in between regardless the distance
你的答案工作太好了,謝謝! –
請問如何匹配「培根,是肉」? –
@YoongKangLim如,要匹配'培根,是meat',而目前所有的那些仍然匹配 - 逗號是可選的? – JosephGarrone