[R] Regex magic anyone?

Johannes Graumann johannes_graumann at web.de
Fri Jan 18 15:29:00 CET 2008


Great!

Joh

On Friday 18 January 2008 15:22:29 Gabor Grothendieck wrote:
> strapply in the gsubfn package can split strings based on
> content rather than delimiters.
>
> > library(gsubfn)
> > strapply(s, ".[(].[)]|.")[[1]]
>
>  [1] "A"    "B"    "C"    "D"    "E"    "F"    "G"    "T(P)" "H"    "I"
> [11] "J"    "K"
>
> See home page at:
> http://gsubfn.googlecode.com
> and vignette:
> library(gsubfn); vignette("gsubfn")
>
> On Jan 18, 2008 9:09 AM, Johannes Graumann <johannes_graumann at web.de> wrote:
> > Hi again,
> >
> > how to elegantly split
> >
> > s <- "ABCDEFGT(P)HIJK"
> >
> > into
> >
> > "A" "B" "C" "D" "E" "F" "G" "T(P)" "H" "I" "J" "K"
> >
> > (independently of which letters 'T' or 'P' actually represent ...).
> >
> > Please jumstart my regexing,
> >
> > Joh
> >
> > ______________________________________________
> > 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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: This is a digitally signed message part.
Url : https://stat.ethz.ch/pipermail/r-help/attachments/20080118/612e5e97/attachment.bin 


More information about the R-help mailing list