[R] regexp,grep: capturing more than one substring

Marc Mamin M.Mamin at intershop.de
Wed Oct 27 10:02:21 CEST 2004


Hello,

I would like to have a function that retrieve matching strings in the same way as with java.util.regex (java 1.4.2).

Example:

f('^.*(xx?)\\.([0-9]*)$','abcxx.785')
=>
c('xx','785')

First of all: Is it possible to achiev this with grep(... perl=TRUE,value=TRUE )?


As I would call this function very often with large data, I'm reluctant to use Sjava for performance reasons.
Is this a wrong assumption that using Java directly would be slower or use more memory than to have a native R function?

Does someone already has a solution for this :)

Thanks,

Marc Mamin




More information about the R-help mailing list