Re: [R] Extract part of string

2014-01-05 Thread arun
Hi, You could try: sub(".*(ron)", "\\1", 'my name is ron') #[1] "ron" #or  sub('^.* ([[:alnum:]]+)$', '\\1','my name is ron') #[1] "ron" A.K. On Sunday, January 5, 2014 11:52 AM, Ron Michael wrote: Hi, I am struggling to extract a part of string using regular expression in R. Let say, the

Re: [R] Extract part of string

2014-01-05 Thread David Winsemius
On Jan 5, 2014, at 9:24 AM, David Winsemius wrote: > > On Jan 5, 2014, at 12:45 AM, Ron Michael wrote: > >> Hi, >> >> I am struggling to extract a part of string using regular expression in R. >> >> Let say, the string to be extracted is 'ron' from the expression 'my name is >> ron'. So I tr

Re: [R] Extract part of string

2014-01-05 Thread David Winsemius
On Jan 5, 2014, at 12:45 AM, Ron Michael wrote: > Hi, > > I am struggling to extract a part of string using regular expression in R. > > Let say, the string to be extracted is 'ron' from the expression 'my name is > ron'. So I tried following: > >> gsub("[^(ron)]", "", 'my name is ron') > [1]

[R] Extract part of string

2014-01-05 Thread Ron Michael
Hi, I am struggling to extract a part of string using regular expression in R. Let say, the string to be extracted is 'ron' from the expression 'my name is ron'. So I tried following: > gsub("[^(ron)]", "", 'my name is ron') [1] "nron" I was expecting to get 'ron', which is not the case. Cou