[R] regex question

Michael Erickson erickson at ucr.edu
Wed Aug 5 07:09:32 CEST 2009

Here's what I came up with:

> gsub("(\\w)[^ ]+[\\b ]", "\\1", astr)
[1] "Timtowtdit"

You might be interested in Regular Expressions Cookbook from O'Reilly
(publisher not author) or http://www.regular-expressions.info/

I usually bumble along knowing there are better ways to do whatever I am doing.


More information about the R-help mailing list