Dear all,
I wanted to remove all punctuations except commas from a string.
I used:
gsub("[[:punct:]]", "", string)
but I don't know how to exclude the commas ",". Anyone would
kindly answer
my basic question?
--
View this message in context:
http://www.nabble.com/Remove-all-punctuations-except-commas-tp24845721p24845721.html
Sent from the R help mailing list archive at Nabble.com.
Try this:
string <- "Aaaa. bbbb, ccc"
gsub("[^,[:alpha:]|[:space:]]", "", string)
On Thu, Aug 6, 2009 at 9:37 AM, Rnewbie <xuancj@yahoo.com> wrote:
>
> Dear all,
>
> I wanted to remove all punctuations except commas from a string.
>
> I used:
>
> gsub("[[:punct:]]", "", string)
>
> but I don't know how to exclude the commas ",". Anyone would
kindly answer
> my basic question?
> --
> View this message in context:
>
http://www.nabble.com/Remove-all-punctuations-except-commas-tp24845721p24845721.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.
>
--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O
[[alternative HTML version deleted]]
Try something along these lines:
gsub("[^[:alnum:][:space:],]", "", string)
On Thu, Aug 6, 2009 at 8:37 AM, Rnewbie<xuancj at yahoo.com>
wrote:>
> Dear all,
>
> I wanted to remove all punctuations except commas from a string.
>
> I used:
>
> gsub("[[:punct:]]", "", string)
>
> but I don't know how to exclude the commas ",". Anyone would
kindly answer
> my basic question?
> --
> View this message in context:
http://www.nabble.com/Remove-all-punctuations-except-commas-tp24845721p24845721.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.
>