fork download
  1. # encoding: UTF-8
  2. def bold_string(str, search)
  3. h = { "e" => "[eéê]", "a" => "[aáâ]" }
  4. regex = search.gsub(/./) {|s| h.fetch(s, s)}
  5. str.gsub(/(#{regex})/i, '<b>\1</b>')
  6. end
  7.  
  8. puts bold_string("Petite bête", "et")
Success #stdin #stdout 0.02s 7432KB
stdin
Standard input is empty
stdout
P<b>et</b>ite b<b>êt</b>e