Skip to content
Back to formatted view

Raw Message

Message-ID: <644e1f320809180157v5896f370j1295d31b7a925b8b@mail.gmail.com>
Date: 2008-09-18T08:57:51Z
From: jim holtman
Subject: character position
In-Reply-To: <!&!AAAAAAAAAAAYAAAAAAAAAAiqk/5CNPFFq17hx4jN18vCgAAAEAAAAINouxDHw1BCtOBv1wpYVw4BAAAAAA==@netcabo.pt>

If it always occurs after 'are', this will work:

> x <-  'There are 20 species in this grid'
> y <- sub(".*are (\\d+).*", "\\1", x, perl=TRUE)
> y
[1] "20"
>


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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?