[R] perl expression question
markleeds at verizon.net
markleeds at verizon.net
Tue Aug 12 22:18:21 CEST 2008
I have a string such as
fileName<-"Agg.20.20.20-all-01".
All I want to do is pull the "20.20.20" and the "all" as strings.
Obviously, they aren't always those values.
The "20.20.20" can be "30.30.30" but it's always after the . which is
next to the second g in Agg and it's always the same length. The all
might not always be "all" but in general it is the text between the two
dashes.
I made an attempt using below but perl expressions and myself are an
extremely bad match ( pun was intended ) and all I got back was the same
string as
fileName in both cases.
weights=sub("^Agg.(\\.*)-\\.*$", "\1",fileName)
dashesstring=sub("^Agg.\\.*-(\\.*)-\\.*$", "\1",fileName)
I could possibly using strsplit but I'm trying to learn perl expressions
as best I can so a solution using that approach is really appreciated.
Thanks.
More information about the R-help
mailing list