Ruby on Rails Regex Delete Array in string or word or in sentences.
Official Ruby logo (Photo credit: Wikipedia) |
I will share to you to delete array in string using regex. Please follow me:
1. using regex str.match(/^.*KOPIKO.*$/) for example
def self.delete_string_with_regex str = "KOPIKO RASA JERUK MANIS DAN MINT" arr = ["KOPIKOS", "JERUK", "COY"] arr.delete_if {|arr| str.match(/^.*#{arr}.*$/)} end
Komentar
Posting Komentar
terimakasih komentarnya