如何扫描文本之间*|
和之间的所有字符串,|*
例如
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"]
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句