取這個字符串。Ruby掃描正則表達式不匹配
a = "real-ab(+)real-bc(+)real-cd-xy"
a.scan(/[a-z_0-9]+\-[a-z_0-9]+[\-\[a-z_0-9]+\]?/)
=> ["real-ab", "real-bc", "real-cd-xy"]
但是,下一個字符串怎麼會變成什麼?
a = "real-a(+)real-b(+)real-c"
a.scan(/[a-z_0-9]+\-[a-z_0-9]+[\-\[a-z_0-9]+\]?/)
=> []
我怎樣才能讓它輸出到3計數數組?
完全不會匹配'real-cd-xy'。 – 2012-04-28 21:49:43
'/ [ - a-z_0-9] + /'will。 – mkjeldsen 2012-04-28 21:51:18