In JavaScript with a regexp I must extract from a long string of text the text contained between two strings "---ST---" and "---EN---", so for example, my text string is:

```
---ST---blah blah blah---EN--- other text ---ST--- foo bar baz ---EN--- other other text ---ST---the cat is on the table---EN---

```

and I must get for every ---ST---/---EN--- couple found an object like this:

```
[{textFound:"blah blah blah", startsAt:0, endsAt:22},
{textFound:" foo bar baz ", startsAt:42, endsAt:64},
...]

```

I tried the following but it doesn't work:

```
function getSTEN(input){

var r =[];
var expression = /---ST---(.*?)---EN---/gi;
var matches = input.match(expression);
for(match in matches)
    {
        var result = {};
        result['textFound'] = matches[match];
        result['startsAt'] = input.indexOf(matches[match]);
        //...
     };

     return r;
};
var str = "---ST---blah blah blah---EN--- other text ---ST--- foo bar baz ---EN--- other other text ---ST---the cat is on the table---EN---";
console.log(getSTEN(str));

```

Can you help me?