str = "<td>What was your first pet's name?</td><td>Another sentence here</td>" sentences = str.scan(/<td>([^<]*)/) last_words_arr = [] for arr in sentences sentence = arr.first sentence.gsub!('?', '') sentence.gsub!('.', '') sentence.gsub!('!', '') last_word = sentence.split.last last_words_arr << last_word end p last_words_arr _______________________________________________ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
- [Wtr-general] How to pick the last word in the sentence sapna
- Re: [Wtr-general] How to pick the last word in the senten... Chong
- Re: [Wtr-general] How to pick the last word in the senten... marekj