Use regmatches present in r base or str_extarct in stringr etc.
> x <- "services as defined in this SOW at a price of € 15,896.80 (if executed fro" > regmatches(x, regexpr("(?<=€ )\\S+", x, perl=T)) [1] "15,896.80"
or
> gsub("€ (\\S+)|.", "\\1", x) [1] "15,896.80"
or
Use of variables.
euro <- "\u20AC" gsub(paste(euro , "(\\S+)|."), "\\1", x)
If this answer using variables will not work for you, you need to set the encoding,
gsub(paste(euro , "(\\S+)|."), "\\1", `Encoding<-`(x, "UTF8"))
A source
source share