I have the following code snippet:
temp <- "44C"
sub("^([-+]?[0-9]+)([CF])$","\\2",temp)
This returns C correctly .
But when I try
temp <- "44"
sub("^([-+]?[0-9]+)([CF])$","\\2",temp)
I was expecting an empty vector. Instead, I get " 44 ".
Am I reasoning something wrong?
source
share