2
如何從掃描和拆分兩種形式的字符串中獲得結果 - 正面和負面匹配?相當於掃描並拆分字符串
def scan_and_split(string, regexp)
string.split(regexp).zip(string.scan(regexp))
end
scan_and_split("{T}: Add {W} or {U} to your mana pool. Adarkar Wastes deals 1 damage to you.", /\{[^ ]+\}/)
預期輸出:
[["", "{T}"], [": Add ", "{W}"], [" or ", "{U}"], [" to your mana pool. Adarkar Wastes deals 1 damage to you.", nil]]
請向我們展示您期待的輸出。 –