Message-ID: <971536df0809180606h197d9897i70670bdf21437071@mail.gmail.com>
Date: 2008-09-18T13:06:57Z
From: Gabor Grothendieck
Subject: character position
In-Reply-To: <!&!AAAAAAAAAAAYAAAAAAAAAAiqk/5CNPFFq17hx4jN18vCgAAAEAAAAINouxDHw1BCtOBv1wpYVw4BAAAAAA==@netcabo.pt>
Try this:
library(gsubfn)
strapply("There are 23 species", "[0-9]+", as.numeric)[[1]]
The gsubfn home pae is at:
http://gsubfn.googlecode.com
On Thu, Sep 18, 2008 at 4:51 AM, Paulo Cardoso <pecardoso at netcabo.pt> wrote:
> Hi,
>
> I'm not being able to capture a position of a 'string' in a character
> string.
>
> In this example: 'There are 20 species in this grid'
>
> I would like to capture the string (number) after 'are' and before
> 'species'. Consider they do not change. I wouldn't like to use substr
> because stop position may change.
>
> Thanks
>
> Paulo
>
> ______________________________________________
> 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.
>