Scala: Find all instances of matching regex and store in array

Viewed 1748

I have a string in Scala. I am trying to find all occurrences of a certain tag and find the text that is enclosed in the tag, storing the results in an array.

So for example, if my string is val string = "<p> c </p> <p> a </p> <p> t </p>" The result I am looking for is:

val result = ["c","a","t"]

What is the best way to do this? Thanks!
Note: I am certain the tag type I am searching for will never appear nested inside another instance of itself, if that helps.

2 Answers
Related