0

I am trying to find a pattern inside a text string. the pattern I am trying to find is the $ sign, and then +2 words on each side.

this code worked for me when I used regular numbers, such as "million", but when I tryied the $ sign, it doesnt work.

here is the code below:

df <- read_xlsx("summary.xlsx")

df_check<-as.data.frame(stringr::str_extract_all(df$detail, utf8::as_utf8("(?:[^\\s]+\\s){2}$(?:\\s[^\\s]+){2}"),simplify = TRUE))

any help will be much appreciated,

thanks!

yneta
  • 1
  • 2
    `$` has a special meaning in regex. Have you tried escaping it with `\\$`. https://stackoverflow.com/questions/27721008/how-do-i-deal-with-special-characters-like-in-my-regex – Ronak Shah Sep 15 '21 at 12:16
  • Please provide enough code so others can better understand or reproduce the problem. – Community Sep 15 '21 at 15:23

0 Answers0