Re: [R] regex - extracting 2 numbers and " from strings

2015-10-09 Thread Omar André Gonzáles Díaz
Yes, you are right. Thank you. 2015-10-08 20:07 GMT-05:00 David Winsemius : > > On Oct 8, 2015, at 4:50 PM, Omar André Gonzáles Díaz wrote: > > > David, it does work but not in all cases: > > It should work if you change the "+" to "*" in the last capture class. It > makes trailing non-digit cha

Re: [R] regex - extracting 2 numbers and " from strings

2015-10-08 Thread David Winsemius
On Oct 8, 2015, at 4:50 PM, Omar André Gonzáles Díaz wrote: > David, it does work but not in all cases: It should work if you change the "+" to "*" in the last capture class. It makes trailing non-digit characters entirely optional. > sub("(^.+ )(\\d+)([\"]|[']{2})(.*$)", "\\2\\3", b) [1] "4

Re: [R] regex - extracting 2 numbers and " from strings

2015-10-08 Thread David Winsemius
On Oct 8, 2015, at 3:45 PM, Omar André Gonzáles Díaz wrote: > Hi I have a vector of 100 elementos like this ones: > > a <- c("SMART TV LCD FHD 70\" LC70LE660", "LED FULL HD 58'' LE58D3140") > > I want to put just the (70\") and (58'') in a vector b. > sub("(^.+ )(\\d+)([\"]|[']{2})(.+$)", "\\2

Re: [R] regex - extracting 2 numbers and " from strings

2015-10-08 Thread David Wolfskill
On Thu, Oct 08, 2015 at 05:45:13PM -0500, Omar André Gonzáles Díaz wrote: > Hi I have a vector of 100 elementos like this ones: > > a <- c("SMART TV LCD FHD 70\" LC70LE660", "LED FULL HD 58'' LE58D3140") > > I want to put just the (70\") and (58'') in a vector b. > > This is my try, but is not w

[R] regex - extracting 2 numbers and " from strings

2015-10-08 Thread Omar André Gonzáles Díaz
Hi I have a vector of 100 elementos like this ones: a <- c("SMART TV LCD FHD 70\" LC70LE660", "LED FULL HD 58'' LE58D3140") I want to put just the (70\") and (58'') in a vector b. This is my try, but is not working: b <- grepl('^[0-9]{2}""$',a) Any hint is welcome, thanks. [[alternati