[R] matching problem

Hans-Joerg Bibiko bibiko at eva.mpg.de
Fri Jun 27 15:59:03 CEST 2008

On 27 Jun 2008, at 13:56, Tom.O wrote:

> Well I have tried that and it's unfortuanally not the solution.
> This return all the characters in the string, but I dont want the  
> characters
> after the ending non-character symbol. Only the starting characters  
> ore of
> interest.
>> gsub("\\W*","", myexstrings,perl=T)
> [1] "AAAAA" "BBBBB" "CCC"   "ddd"


try this one:

gsub("^\\W*(\\w+)\\W.*","\\1", myexstrings,perl=T)


More information about the R-help mailing list