Just a quick question, does anyone know how to use regexpr with "\$" ? Essentially, I want to parse out strings and figure out what numeric value came after the \$ (for example "Get $50 off on p开发者_开发知识库urchases of new bed frames").
In regular expressions, $
would denote the end of the string, and so if you want to match an actual $, you'd need to "escape" it, like \$
.
In grep
in R, you need to use \\
, as follows:
x <- "Get $50 off on purchases of new bed frames"
grep("\\$\\d+", x)
精彩评论