[R] regex and sub
arnaud Gaboury
arnaud.gaboury at gmail.com
Fri May 14 12:10:45 CEST 2010
Dear group,
Here is an object:
z <-
c("LSCPos100415.csv", "LSCPos100416.csv", "LSCPos100419.csv",
"LSCPos100420.csv", "LSCPos100421.csv", "LSCPos100422.csv",
"LSCPos100423.csv",
"LSCPos100426.csv", "LSCPos100427.csv", "LSCPos100428.csv",
"LSCPos100429.csv",
"LSCPos100430.csv", "LSCPos100503.csv", "LSCPos100504.csv",
"LSCPos100505.csv",
"LSCPos100506.csv", "LSCPos100507.csv", "LSCPos100510.csv",
"LSCPos100511.csv",
"LSCPos100512.csv", "LSCPos100513.csv")
I want to keep only the numeric part of each element.
I thought using something like :
>sub("REGEX","",y)
I tried something with " \\D+", but it is not the final result I want
> sub("\\D+","",y)
[1] "100415.csv" "100416.csv" "100419.csv" "100420.csv" "100421.csv"
"100422.csv" "100423.csv" "100426.csv" "100427.csv" "100428.csv"
"100429.csv" "100430.csv" "100503.csv" "100504.csv" "100505.csv"
[16] "100506.csv" "100507.csv" "100510.csv" "100511.csv" "100512.csv"
"100513.csv"
TY for help
More information about the R-help
mailing list