s-news
[Top] [All Lists]

Re: regexpr problem

To: array chip <arrayprofile@yahoo.com>
Subject: Re: regexpr problem
From: Sundar Dorai-Raj <sundar.dorai-raj@pdf.com>
Date: Thu, 28 Aug 2003 13:46:13 -0500
Cc: s-news@wubios.wustl.edu
In-reply-to: <20030828183001.62185.qmail@web41215.mail.yahoo.com>
Organization: PDF Solutions, Inc.
References: <20030828183001.62185.qmail@web41215.mail.yahoo.com>
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)
Use "^" to match the beginning of a string. I'm not sure how the "()" is interpretted.

S> regexpr("^JA?[0-9]+","JA87")
[1] 1
attr(, "match.length"):
[1] 4
S>  regexpr("^JA?[0-9]+","JB87")
[1] -1
attr(, "match.length"):
[1] -1

R> regexpr("^JA?[0-9]+","JA87")
[1] 1
attr(,"match.length")
[1] 4
R> regexpr("^JA?[0-9]+","JB87")
[1] -1
attr(,"match.length")
[1] -1

array chip wrote:
Hi,

I encountered a problem using "regexpr". The code
works fine in R, but not in S-Plus:

when run in R, it shows what I wanted (and it make
sense as well):

regexpr("(JA)?[0-9]+","JA87")

[1] 1
attr(,"match.length")
[1] 4

but if I try it in S-Plus:

regexpr("(JA)?[0-9]+","JA87")

[1] -1
attr(, "match.length"):
[1] -1

Basically, I wanted to match a pattern where there
might be letters "JA" preceding some numbers. Is there
something wrong with my code, or this a bug is S-Plus?

Thanks




__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu.  To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message:  unsubscribe s-news



<Prev in Thread] Current Thread [Next in Thread>