Re: [R] Regex to stop at first capital letter after sequence

2016-12-19 Thread Bert Gunter
You don't need a regex. ?strsplit Something like: > y <-c("PPA 06 - Promo Vasito", "PPA 05 - Cuentos") > sapply(strsplit(y, "-"),"[",2) [1] " Promo Vasito" " Cuentos" You may have to add spaces around your "-" , as you failed to supply data so I cannot be sure what you have. -- Bert Bert G

Re: [R] Regex to stop at first capital letter after sequence

2016-12-19 Thread Sarah Goslee
Hi, If your actual data are of the same form as your sample data, why not just: x <- c("PPA 06 - Promo Vasito", "PPA 05 - Cuentos", "PPA 04 - Promo vasito", "PPA 03 - Promoción escolar", "PPA - Saluda a tu pediatra", "PPL - Dia del Pediatra") sub("^.* - ", "", x) [1] "Promo Vasito" "Cuent

Re: [R] Regex to stop at first capital letter after sequence

2016-12-19 Thread David Winsemius
> On Dec 19, 2016, at 1:25 PM, Omar André Gonzáles Díaz > wrote: > > I have the following strings: > > [1] "PPA 06 - Promo Vasito" [2] "PPA 05 - Cuentos" > [3] "PPA 04 - Promo vasito" [4] "PPA 03 - Promoción escolar" > [5] "PPA - Saluda a tu pediatra" [6] "PPL - Dia del Pediatra" >

[R] Regex to stop at first capital letter after sequence

2016-12-19 Thread Omar André Gonzáles Díaz
I have the following strings: [1] "PPA 06 - Promo Vasito" [2] "PPA 05 - Cuentos" [3] "PPA 04 - Promo vasito" [4] "PPA 03 - Promoción escolar" [5] "PPA - Saluda a tu pediatra" [6] "PPL - Dia del Pediatra" *Desired result*: [1] "Promo Vasito" "Cuentos""Pro