I am trying to subset a string from the back based on occurrence of underscores. Example follows:

```
string <- "trash_trash_trash_keep_keep_keep_trash.trash" 

```

I am trying to substring from the last underscore till an nth occurrence. In this example, the desired output is:

```
"keep_keep_keep"

```

My attempt so far is messing up: `'^(?:[^_]*){3}(.+)_'` I think I should address the problem from the back, instead the start of the string.

Any input is appreciated.