Posts with the tag ruby:

A challenge: remove tags from a string.

Recently I have implemented a small piece of functionality, which is suitable to be a small challenge. Description Given a string with opening and closing tags (e.g., <mark></mark>), return a string without tags and indices of opening and closing tags. For example, given a string: "we eat <mark>healthy</mark> and <mark>tasty</mark> food." We expect to receive a string: "we eat healthy and tasty food.", and an array with pairs of indices: [[7, 14], [19, 24]]. There are two pairs of indices, because there were two pairs of <mark></mark> tags. Ruby First, I tried to solve this problem imperative way, which did not work very well.