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" Regards Tom Hans-Jörg Bibiko wrote: > > > On 27 Jun 2008, at 12:23, Tom.O wrote: > >> >> Hi R gurus >> I have a matching problem that I cant solve. I have tried multiple >> solutions >> and searched varius help-sites but I cant get it to work. >> >> This is the problem >> myexstrings = c("*AAA.AA","BBB BB","*.CCC.","**dd- d") >> >> what I want do do is to remove any non-characters in the beginning and >> everything else after the non-character symbol after the first set of >> characters so that the string becomes: >> >> c("AAA","BBB","CCC","dd") >> >> >> I can figure out the start, sub("^\\W*","", myexstrings,perl=T) will >> remove >> the unwanted beginnings but then its the rest. > > Try > > gsub("\\W*","", myexstrings,perl=T) > > Cheers, > > --Hans > > ______________________________________________ > 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. > > -- View this message in context: http://www.nabble.com/matching-problem-tp18152158p18153583.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.