s-news
[Top] [All Lists]

regMatchPos

To: <s-news@lists.biostat.wustl.edu>
Subject: regMatchPos
From: "Andrew Scott" <ascott@icfrith.com.au>
Date: Wed, 17 Aug 2005 12:15:42 +1000
Thread-index: AcWi0ZGKkxxoH1EXRlGOrm3oDpzkzQ==
Thread-topic: regMatchPos
Hi all,

Just trying to use regMatchPos to pick out the 2nd and 3rd occurrences of a 
space character (" ") from within a string vector so that I can isolate 
peoples' surnames.

Thus I want to convert:

"Mr John Smith"         to      "Smith"
or
"Mr Smith"              to      "Smith"
or
"Smith"                 to      "Smith"

(In fact, the solution requires the detection of the last occurrence of a space 
(" ") or the presence of no spaces at all.)

In another example, I have been able to identify the text between a "/" 
character and the 1st occurrence of a " " using the following:

StPos<-regMatchPos(ProdName,"/")[,1]
EndPos<-regMatchPos(ProdName," ")[,1]
TempBrand<-as.factor(substring(ProdName,StPos+1,EndPos-1))

Thus    "Computer/Type Model"   becomes "Type"

I've referred to the help screen and S-Plus manual on "regMatchPos" and these 
refer to "extended tables" and "egrep" but otherwise don't go much further.

Any assistance would be appreciated. (I'm sure this problem has been solved 
many times before).

Andrew G. Scott, BEc FIAA
Manager - Strategic Analysis and Product Development
IC Frith and Associates





*****************************************************************************************************************************************************
The information contained in this email and any attached files is strictly 
confidential and may contain legally privileged information. 
This email should be read by the intended addressee only. If the recipient of 
this message is not the intended addressee, please 
advise IC Frith & Associates on +61 2 8853 9100 or ascott@icfrith.com.au and 
promptly delete this email and any attachments. 

The intended recipient of this email may only use, reproduce, disclose or 
distribute the information contained in this email and 
any attached files with IC Frith & Associates permission. If you are not the 
intended addressee, you are strictly prohibited from 
using, reproducing, disclosing or distributing the information contained in 
this email and any attached files. 

Although IC Frith & Associates believes this e-mail and any attachments to be 
free of any virus or other defect which may effect 
your computer, it is the responsibility of the recipient to ensure that it is 
virus free and IC Frith & Associates does not accept any 
responsibility for any loss or damage arising in any way from its use.

We maintain a database of clients' contact details. If you do not wish to 
receive electronic messages from us in future please 
email icfteam@icfrith.com.au.

Finally, you should be aware IC Frith & Associates reserves the right and 
intends to intercept and monitor incoming and outgoing 
e-mail correspondence, so you should not expect any e-mail communication to be 
private in nature.

IC Frith & Associates Pty Ltd ABN 48 097 088 287 AFSL No:230625 

*****************************************************************************************************************************************************



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