Given an array such as words = ["hello", ", ", "world", "!"], I am required to manipulate the elements which are made up of letters, so I will get a string in the end such as "*hello*, *world*!"
I have managed to retrieve the indexes from the array which contain letters using words.map.with_index { |element, index| index if element[[/a-zA-Z+/]] == element }.compact, which are [0, 2].
How could I use these indexes in a function, such that I could manipulate the words?
Stringand then manipulate it using the methodsStringprovideswords.join.gsub(/\w+/) {|m| "*#{m}*"}words.join.gsub(/\w+/,'*\0*').words.join.gsub(/\b/, '*').'*\0*'do exactly?