Greg Snow wrote:
> Here is one way using a single pattern (so can be used in a substitution), it 
> uses Perl's positive look ahead patters:
>
>   
>> test <- 
>> c("SHRT","5HRT","M1TCH","M1TCH5","LONG3RS","NONUMBER","TOOLOOOONGG","ooops.3")
>>
>> sub( '(?=[a-zA-Z]{0,8}[0-9])[a-zA-Z0-9]{5,9}', 'xxx', test, perl=TRUE)
>>     


yes, but:

    sub( '(?=[a-zA-Z]{0,8}[0-9])[a-zA-Z0-9]{5,9}', 'xxxxx', '12345',
perl=TRUE)
    # "xxxxx"

which is not what was expected -- as far as i understand, the point was
to match 5-9 character strings with exactly 1 digit.

vQ

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to