In the string I am trying to extract the 0.4%
that comes after 12 month(s)\n$500
I search for 12 month(s)\n$500
and then grab number dot number that comes after.
From here, "To match a literal “$” or “^”, you need to escape them, $, and ^." But when I do that, I get the error:
Error: '\$' is an unrecognized escape in character string starting ""(?<=12 month(s)\\n\$"
What am I doing wrong?
x <- "Term Minimum investment Rate Interest type Get this GIC\n3 month(s)\n$500 0.15% Simple\nChoose this GIC\n6 month(s)\n$500 0.25% Simple\nChoose this GIC\n9 month(s)\n$500 0.30% Simple\nChoose this GIC\n12 month(s)\n$500 0.40% Simple\nChoose this GIC\n18 month(s)\n$500 0.50% Simple\nChoose this GIC\n18 month(s)\n$500 0.50% Compound\nChoose this GIC"
as.numeric(stringr::str_extract(x, "(?<=12 month(s)\\n\$500)\\d\\.\\d{1,}"))