-1
我如何將以下各項與正則表達式匹配?如何在ruby中執行以下正則表達式?
some text includes [any number of character].
需要拉動整個[asdfasdf]
@tableid='sometext'
我需要拉sometext
mary and drugs
我需要拉 「和」,包含空格。
我如何將以下各項與正則表達式匹配?如何在ruby中執行以下正則表達式?
some text includes [any number of character].
需要拉動整個[asdfasdf]
@tableid='sometext'
我需要拉sometext
mary and drugs
我需要拉 「和」,包含空格。
嘗試這些:
"\[(.*?)\]"
"@\w+='(.*?)'"
" +and +"
irb(main):002:0> "some text include [abcdef]".match(/\[(.*)\]/)[1]
=> "abcdef"
irb(main):005:0> "@table_id='2356'".match(/'(.*)'/)[1]
=> "2356"
irb(main):006:0> "mary and drugs".match(/mary(.*)drugs/)[1]
=> " and "
-1不遺餘力。 – 2012-03-26 22:35:07