Ruby on Rails Regex Delete Array in string or word or in sentences.

Official Ruby logo
Official Ruby logo (Photo credit: Wikipedia)
Hi all,

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
Enhanced by Zemanta

Komentar

Postingan populer dari blog ini

EPrT English Proficiency Test Soal - soal

cara memunculkan dan menyembunyikan icon date, time, clock, volume, network, power battery, action center pada taskbar pada Windows 7