Re: [R] Locating the starting position of the first number in a string

2015-11-02 Thread Boris Steipe
The regular expression you are looking for is \d{5} ... a "digit" repeated five times. Note that you have to escape the escape in an R string. But your example does not conform to the description: you have examples with six digit numbers: IBBS3_MSM_HN104213. If there is length variation, I wou

Re: [R] Locating the starting position of the first number in a string

2015-11-02 Thread Jeff Newmiller
digits then split at the first number (i.e., HN and 104213). HTH . Peter Alspach -Original Message----- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Jennifer Sabatier Sent: Tuesday, 3 November 2015 7:39 a.m. To: r-help@r-project.org Subject: [R] Locating

Re: [R] Locating the starting position of the first number in a string

2015-11-02 Thread Peter Alspach
Peter Alspach -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Jennifer Sabatier Sent: Tuesday, 3 November 2015 7:39 a.m. To: r-help@r-project.org Subject: [R] Locating the starting position of the first number in a string Hi, So, I've got a vector

[R] Locating the starting position of the first number in a string

2015-11-02 Thread Jennifer Sabatier
Hi, So, I've got a vector of strings that look like this: ID <- c("IBBS3_MSM_HN01209","IBBS3_MSM_HN01210","IBBS3_MSM_HN01211", "IBBS3_MSM_HN10212","IBBS3_MSM_HN104213","IBBS3_MSM_HN10214", "IBBS3_MSM_HN44215","IBBS3_MSM_HN44216","IBBS3_MSM_HN44217", "IBBS3_MSM_HN44218","IBBS3_MSM_HN44219","IBBS3_