I would like to use str_extract in the stringr package to extract the numbers from strings in the form XX nights etcetc
.
I'm currently doing this:
library(stringr)
str_extract("17 nights$5 Days", "(\\d)+ nights")
but that returns
"17 nights"
instead of 17
.
How can I extract just the number? I thought specifying the extract group with parentheses would work, but it doesn't.