Question: I am trying to use a regular expression in order to extract the part of a string before the first " / " occurrence. In the following example the initial string is "Atomic grouping / possessive qualifiers / conditional and recursive patterns" and i want to get "Atomic grouping"

```
library(stringr)
var.descr <- "Atomic grouping / possessive qualifiers / conditional and recursive patterns"

```

I tried the following but it matches the string until the `last` " / " occurrence (it returns "Atomic grouping / possessive qualifiers")

```
str_extract(var.descr, perl("^.+(?=\\s/)"))

```

Any help would be gratefully appreciated.

Answer: 
You can use lookahead regex like this:

```
str_extract(var.descr, perl("^.+?(?= / |$)"))

```

`(?= / |$)` will make sure either `/` is followed by the matched text or it matches till end of input.

[RegEx Demo](https://regex101.com/r/jF6fW9/3)
You can use the "lazy" `+` with `?` after it

```
str_extract(var.descr, perl("^[^/]+"))

```