[R] Retain last grouping after a strsplit()

jim holtman jholtman at gmail.com
Tue Dec 11 19:10:07 CET 2012


try this:

> x
[1] "OYS-PIA2-FL-1"  "OYS-PIA2-LA-1"  "OYS-PI-LA-BB-1" "OYS-PIA2-LA-10"
> sub("^.*?([0-9]+)$", "\\1", x)
[1] "1"  "1"  "1"  "10"
>



On Tue, Dec 11, 2012 at 12:46 PM, Steven Ranney <steven.ranney at gmail.com> wrote:
> OYS-PIA2-FL-1
> OYS-PIA2-LA-1
> OYS-PI-LA-BB-1
> OYS-PIA2-LA-10



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.




More information about the R-help mailing list