Re: [R] Extracting part of alpha numeric string

2015-11-30 Thread Berend Hasselman
> On 30 Nov 2015, at 14:57, phgrosj...@sciviews.org wrote: > > >> On 30 Nov 2015, at 13:09, Abhinaba Roy wrote: >> >> Hey, >> >> worked like a charm! :) >> >> Could you please explain about >> >> sub("^([0-9]*).*$", "\\1", fields) >> > > Yes. > > sub() replaces substrings. The first argu

Re: [R] Extracting part of alpha numeric string

2015-11-30 Thread phgrosjean
> On 30 Nov 2015, at 13:09, Abhinaba Roy wrote: > > Hey, > > worked like a charm! :) > > Could you please explain about > > sub("^([0-9]*).*$", "\\1", fields) > Yes. sub() replaces substrings. The first argument captures the interesting part of the string: ^ = start of the string, ([0-9

Re: [R] Extracting part of alpha numeric string

2015-11-30 Thread S Ellison
> Could you please explain about > > sub("^([0-9]*).*$", "\\1", fields) See ?regex and the extensive online literature on regular expressions. S Ellison *** This email and any attachments are confidential. Any use...{{dropped:8}

Re: [R] Extracting part of alpha numeric string

2015-11-30 Thread Abhinaba Roy
Hey, worked like a charm! :) Could you please explain about sub("^([0-9]*).*$", "\\1", fields) Thanks, Abhinaba On Mon, Nov 30, 2015 at 4:47 PM, wrote: > fields <- c("2154333b-3208-4519-8b76-acaef5b5a479", > "980958a0-103b-4ba9-afaf-27b2f5c24e69", > "00966654-0dea-4899-b8cf-26e83

Re: [R] Extracting part of alpha numeric string

2015-11-30 Thread phgrosjean
fields <- c("2154333b-3208-4519-8b76-acaef5b5a479", "980958a0-103b-4ba9-afaf-27b2f5c24e69", "00966654-0dea-4899-b8cf-26e8300b262d") sub("^([0-9]*).*$", "\\1", fields) Best, Philippe Grosjean > On 30 Nov 2015, at 11:39, Abhinaba Roy wrote: > > Hi, > > I have a field with alpha num

[R] Extracting part of alpha numeric string

2015-11-30 Thread Abhinaba Roy
Hi, I have a field with alpha numeric codes like, 2154333b-3208-4519-8b76-acaef5b5a479 980958a0-103b-4ba9-afaf-27b2f5c24e69 00966654-0dea-4899-b8cf-26e8300b262d I want a derived field which will contain ONLY the numeric part before the first alphabet and the first '-', for example the derived fi