-----Original Message-----
From: Henrique Dallazuanna [mailto:wwwhsd at gmail.com]
Sent: quinta-feira, 18 de Setembro de 2008 12:14
To: Paulo Cardoso
Cc: jim holtman; r
Subject: Re: [R] character position
Try:
sub(".*FILE (\\w+)|\\.*", "\\1", x, perl=TRUE)
On Thu, Sep 18, 2008 at 7:39 AM, Paulo Cardoso <pecardoso at netcabo.pt>
wrote:
Perfect but when one wants to get something different, like
x <- 'INPUT FILE record.dat'
sub(".*FILE (\\w+).*", "\\1", x, perl=TRUE)
will return 'record' and not 'record.dat'
the [:punct:] is not retained.
Paulo
-----Original Message-----
From: jim holtman [mailto:jholtman at gmail.com]
Sent: quinta-feira, 18 de Setembro de 2008 9:58
To: Paulo Cardoso
Cc: r
Subject: Re: [R] character position
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
On Thu, Sep 18, 2008 at 4:51 AM, Paulo Cardoso
<pecardoso at netcabo.pt>
Hi,
I'm not being able to capture a position of a 'string' in a
string.
In this example: 'There are 20 species in this grid'
I would like to capture the string (number) after 'are' and
'species'. Consider they do not change. I wouldn't like to use
because stop position may change.
Thanks
Paulo