How to store the search matches from id="post_body"
to array?
<textarea name="post[body]" id="post_body">
--Lorem ipsum-- dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et --Dolore-- magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. --Duis aute-- irure dolor in reprehenderit in voluptate velit esse cillum --Dolore-- eu fugiat nulla pariatur
</textarea>
The target are all words surrounded by '--'. In Ruby, I do that with:
matches = tex.scan(/--(.+?)--/).flatten
matches = matches.uniq
In this case, the array would be:
matches = ["Lorem ipsum", "Dolore", "Duis aute"];
NB: the word "Dolore" appears twice surrounded with --
, but in the array it should be stored only once.