我需要匹配(单词)...... ......之间的一切......(第一名:(或))
输入
您可以开车去机场或乘坐出租车但不要在那里散步或骑自行车。
匹配
你可以either
开车到机场or
乘坐出租车,但不要在那里散步或骑自行车。
输出
either
开车前往机场or
(either\s).*(\sor)
但它不会得到第一个或......
a = "You can either drive to the airport or get a taxi but don't walk or bike there."
b = /(either\s).*(\sor)/g.exec(a)
console.log(b[0])

答案 0 :(得分:1)
您正在寻找的是:
/(either\s).+?(\sor)/g
a = "You can either drive to the airport or get a taxi but don't walk or bike there."
b = /(either\s).+?(\sor)/g.exec(a)
console.log(b[0])