Hi, I'm trying to write a regular expression that captures numbers in the form 9,007,653,372,262.48 but does not capture dates in the form 09/30/2005 I have tried numerous expressions, but they all seem to return the dates as well. Thanks. [[alternative HTML version deleted]]
On 04-Mar-09 07:55:11, Bob Roberts wrote:> Hi, > I'm trying to write a regular expression that captures numbers in the > form 9,007,653,372,262.48 but does not capture dates in the form > 09/30/2005 > I have tried numerous expressions, but they all seem to return the > dates as well. Thanks.Testing the regular expression [0123456789,.][^/]* with grep (on Linux, R is not involved in this test): $ grep '[ ][0123456789,.][^/]*[ ]' << EOT> A line with no numbers > This is 9,007,653,372,262.48 one line > Another no-numbers > This is 09/30/2005 another line > Yet another no-numbers > EOTThis is 9,007,653,372,262.48 one line Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 04-Mar-09 Time: 09:30:17 ------------------------------ XFMail ------------------------------
Not clear what else is allowed to match and what not but this will match strings of numbers commas and decimal points but not match if there is anything else in the string like a slash: regexpr("^[0-9.,]+$", "9,007,653,372,262.48") On Wed, Mar 4, 2009 at 2:55 AM, Bob Roberts <quagmire54321 at yahoo.com> wrote:> Hi, > ?I'm trying to write a regular expression that captures numbers in the form 9,007,653,372,262.48 but does not capture dates in the form 09/30/2005 > I have tried numerous expressions, but they all seem to return the dates as well. Thanks. > > > > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > 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. >