2013-12-13 79 views

回答

3

使用String#include?

note.attachment_content_type.include?("image")

2

您可以使用Regexp

if note.attachment_content_type =~ /image/ 
    puts "Found" 
end 
1

我會用String#[]

note.attachment_content_type[/image/] 
+0

嗨奧雅納。我很好奇你的推理。爲什麼在'String#include?'或者正則表達式匹配上使用'Sring#[]'? – silasjmatson

+0

@Silasj No..'Sring#[]'not over'String#include?'..只是另一種方式..你有沒有使用它?我的意思是'String#[]'? :) –

+0

我很少使用'String#[]'。通常我使用'#slice'。我從來沒有想過這樣...猜猜這就是紅寶石的美麗。 – silasjmatson

相關問題