Question: I have regex:

```
(?<=<start>\n)([^\n]+\n)+(?=<end>)

```

And the text:

```
<start>
123
456
789
<end>

```

Expected result is:

* Match 1: 123
* Match 2: 456
* Match 3: 789

Actual result is:

* Match 1: 789

How can I modify my regex to get expected result?

Answer: 
Using PCRE regex engines that support `\G`:

```sh
(?:<start>(?=[\s\S]*<end>)|(?<!\A)\G)\s\K(?!<end>)\S+

```

**Regex Details:**

* `(?:`: Start non-capture group
* `<start>`: Match `<start>`
* `(?=[\s\S]*?<end>)`: Assert that we have a line `<end>` ahead of us
* `|`: OR
* `(?<!\A)\G)`: Start from the end of the previous match
* `\s`: Match a whitespace
* `\K`: Reset match info
* `(?!<end>)`: Don't match `<end>`
* `\S+`: Match 1+ non-whitespace characters

[RegEx Demo](https://regex101.com/r/mg9vU3/3)

---

Alternatively, if you're using Javascript that now support dynamic length lookbehind like `.Net`:

```sh
(?<=<start>\n[^]*)^.+(?=[^]*<end>)

```

[RegEx Demo 2](https://regex101.com/r/ql9gZZ/1)
When you quantify a capture group, it only captures the last occurrence.

The trick is to put a capture group *around* the quantified group to get all of them.

```
(?<=<start>\n)((?:[^\n]+\n)+)(?=<end>)

```