我有一个像下面这样的向量:
x <- c('3b and to 10 am ','1c and to 12 pm','#01-93 and to 10 am ')
我需要将所有不带字符串am或pm的数字替换为“ none”。所以我尝试使用
sub('.*-([0-9]+).*','none',x)
但这不起作用。 我的预期输出如下:
x <- c('none and to 10 am ','none and to 12 pm','none and to 10 am ')
感谢您的帮助。