[英]Find all matches between two strings with Ruby regex
如何掃描*|
之間的所有字符串 和|*
文字
Today is *|date|*. Weather is *|weather_description|*.
使用Ruby "string...".scan(...)
。
我想要匹配的數組: ["date", "weather_description"]
。
"Today is *|date|*. Weather is *|weather_description|*.".scan(/\*\|(.*?)\|\*/).flatten
# => ["date", "weather_description"]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.