使用Ruby正则表达式查找两个字符串之间的所有匹配项

使用Ruby正则表达式查找两个字符串之间的所有匹配项,ruby,regex,Ruby,Regex,如何在文本中扫描*和*之间的所有字符串,如 Today is *|date|*. Weather is *|weather_description|*. 使用Ruby“字符串…”。扫描(…) 我想获得一系列匹配项:[“日期”,“天气描述”]谢谢!工作很有魅力。你在过去的几个月里取得了很大的进步! "Today is *|date|*. Weather is *|weather_description|*.".scan(/\*\|(.*?)\|\*/).flatten # => ["dat

如何在文本中扫描
*
*
之间的所有字符串,如

Today is *|date|*. Weather is *|weather_description|*.
使用Ruby
“字符串…”。扫描(…)


我想获得一系列匹配项:
[“日期”,“天气描述”]

谢谢!工作很有魅力。你在过去的几个月里取得了很大的进步!
"Today is *|date|*. Weather is *|weather_description|*.".scan(/\*\|(.*?)\|\*/).flatten
# => ["date", "weather_description"]