regex - How to find the strings DO NOT starts with "2012" using regular expressions? -


hi have date format strings, , want find out ones not start "2012" using regular expression (in r). have tried grep("^[^2012]",dataset) did not work. , have tried grep("^[^2][^0][^1][^2]",dataset) , still did not work. pattern question? appreciated.

you can use ! in front of grepl:

 x[ !grepl("^2012", x) ] 

grep("^[^2012] , ...) reject values started of digits. (i'm not sure why second 1 didn't work.) gustav's suggestion works if specify perl=true:

x[ grep("^(?!2012)", x, perl=true) ] 

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

image - ClassNotFoundException when add a prebuilt apk into system.img in android -