[R] searchina a pattern in a string

2012-04-24 Thread arunkumar1111
I have a long string. i want to sepearate a 10 digit phone no from it. eg my no is 9876543210 is personal no and my official no is 123-456-8907. you can use any of these i want to seperate the 9876543210 and 123-456-8907 from this. therev may be many phone nos in the string. how to do it

Re: [R] searchina a pattern in a string

2012-04-24 Thread Tal Galili
If it was only numbers with no dashes or up to 2 dashes, you can do it like this: require(stringr) STRING - my no is 9876543210 is personal no and my official no is 123-456-8907. you can use any of these str_extract_all( STRING , [0-9]+-*[0-9]+-*[0-9]+) (and then clean the numbers...)

Re: [R] searchina a pattern in a string

2012-04-24 Thread Gabor Grothendieck
On Tue, Apr 24, 2012 at 10:52 AM, arunkumar akpbond...@gmail.com wrote: I have a long string. i want to sepearate a 10 digit phone no from it. eg my no is 9876543210 is personal no and my official no is 123-456-8907. you can use any of these i want to seperate the 9876543210 and