簡體   English   中英

使用Ruby正則表達式查找兩個字符串之間的所有匹配項

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM