正如這個標題所暗示的那樣,我希望得到一些字符,並檢查它們是否屬於任何字符串。如果我想,例如,「!」被禁止,然後string.replace("",word_with_!)
。如果forbidden_chars是一個數組,我該如何檢查禁止的字符?從包含某個字符的紅寶石中清除單詞
forbidden_chars = ["!",",",...]
check ARRAY (it is the string split into an array) for forbidden chars
erase all words with forbidden chars
任何人都可以幫助我嗎?我只是考慮在卡片上搜索單詞並在檢索答案中強制性地檢索索引。非常感謝你:)
看'gsub'方法 - http://ruby-doc.org/core-2.2.3/String.html#method-i-gsub –