0
name="(this is
a message
)
(other message)";
res=name.scan(/(\(.*\))/m);
puts res.join("###");
在上面的代碼中,我想提取與它內部文本匹配的括號作爲整體表達。在紅寶石中尋找匹配字符串的模式
我的意思是我想通過我的代碼得到以下結果:
(this is
a message
)###(other message)
這就是說,對資源的長度應爲2而不是1, 但在我的代碼,我總是得到:
(this is
a message
)
(other message)
我的模式一定有問題,任何人都可以幫我解決它嗎?