extract Zahl nach spezifischer Zeichenkette
Ich muss die Nummer nach der Zeichenfolge "Count of" finden. Zwischen der Zeichenfolge "Count of" und der Zahl kann sich ein Leerzeichen oder ein Symbol befinden. Ich habe etwas, das auf www.regex101.com funktioniert, aber nicht mit stringr @ funktionierstr_extract
Funktion.
library(stringr)
shopping_list <- c("apples x4", "bag of flour", "bag of sugar", "milk x2", "monkey coconut 3oz count of 5", "monkey coconut count of 50", "chicken Count Of-10")
str_extract(shopping_list, "count of ([\\d]+)")
[1] NA NA NA NA "count of 5" "count of 50" NA
Was ich bekommen möchte:
[1] NA NA NA NA "5" "50" "10"