I have a long string:

```
my_string = "GTCAGTCGATCTGGGCATTATGCGTCAAAAGGCTGCTAGCTAAAGCTGATCAGCATCAAAAGGCCGCCCCTATGCTACGAGCATCATGCATCTGGGTCTAGCTAGTGGGCATTCTCTCTGCTGCATTCAGTCACAAAAGGTGTCAGTCGTAGTCATCATCTACATCGTTCATGCTGGGCATTACAGTCAGTCACAAAAGGTCAGTCAGTCA"

```

I want to extract two things from this string:

1. Everything "*before*" the **first** encountered CAAAAG
2. Everything "*after*" the **last** encountered TGGGCATT

Everything before CAAAAG can be found like this:

```
stringr::word(my_string, 1, sep = "CAAAAG")

```

But how do I make sure that it is "first" CAAAAG in the string? And that I am receiving all characters found **before the very first** CAAAAG?

The same goes for TGGGCATT. I can receive everything "after" TGGGCATT in this way:

```
stringr::word(my_string, -1, sep = "TGGGCATT")

```

But how do I make sure that I am getting all characters coming "after" the **LAST** TGGGCATT in my string?