[R] Regexp subexpression

Dieter Menne dieter.menne at menne-biomed.de
Sat Mar 25 17:32:03 CET 2006


Dieter Menne <dieter.menne <at> menne-biomed.de> writes:

> 
>   patid=c("ALAN334","AzD44","44AZD")
>   txt =sub("([[:alpha:]]+)([[:digit:]])+","\\1",patid)
>   num =sub("([[:alpha:]]+)([[:digit:]])+","\\2",patid)
> 

Sorry, a ")" was at the wrong place. Here the corrected version.

   patid=c("ALAN334","AzD44","44AZD")
   txt =sub("([[:alpha:]]+)([[:digit:]]+)","\\1",patid)
   num =sub("([[:alpha:]]+)([[:digit:]]+)","\\2",patid)


Dieter




More information about the R-help mailing list