[R] Searching 1st number within a ch. string

Gabor Grothendieck ggrothendieck at gmail.com
Fri Sep 11 15:08:13 CEST 2009


Try this:

> regexpr("[0-9]", "asd123")
[1] 4
attr(,"match.length")
[1] 1


On Fri, Sep 11, 2009 at 9:02 AM, RON70 <ron_michael70 at yahoo.com> wrote:
>
> Hi all,
>
> Is there any process to conduct a search for a particular digit or letter in
> a ch. string? For example I want to make a search where 1st numeric figure
> appears in the string "asd123". Here the answer should be "4"
>
> Thanks,
> --
> View this message in context: http://www.nabble.com/Searching-1st-number-within-a-ch.-string-tp25400580p25400580.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>




More information about the R-help mailing list