這裏是我的文字:如何限制正則表達式來捕獲小
"A popular resource for the Christian community in the Asheville area."
"I love the acting community in the Orange County area."
我想拍攝"Asheville"
和"Orange County"
。我怎樣才能從最接近的"the"
到"area"
?
這裏是我的正則表達式:
/the (.+?) area/
他們捕捉:
"Christian community in the Asheville"
"acting community in the Orange County"
這是否工作'/((?:(?!the)。)+?面積/'? [Demo](https://regex101.com/r/qWQ4aS/1/) – degant
'/ \ b(([AZ] [az] + \ s?)+ \ b)(?= area)/'可能是好。 –
有趣的問題。使用String和Enumerable方法找不到令人滿意的解決方案。 –