Unless I am missing something, this regex seems pretty straightforward:
grepl("Processor\.[0-9]+\..*Processor\.Time", names(web02))
However, it doesn’t like the escaped periods, \. for which my intent is to be a literal period:
Error: '\.' is an unrecognized escape in character string starting "Processor\."
What am I misunderstanding about this regex syntax?
My R-Fu is weak to the point of being non-existent but I think I know what’s up.
The string handling part of the R processor has to peek inside the strings to convert
\nand related escape sequences into their character equivalents. R doesn’t know what\.means so it complains. You want to get the escaped dot down into the regex engine so you need to get a single\past the string mangler. The usual way of doing that sort of thing is to escape the escape:Embedding one language (regular expressions) inside another language (R) is usually a bit messy and more so when both languages use the same escaping syntax.