Remove character at end of text string

  • Follow


I have a list of phone numbers (7 & 10 digit) and many (but not all) of them
have an extra dash "-" at the end of the number.  Is there anyway to delete
just the last extra dash without deleting all?   The numbers have 2, 3 or 4
dashes and I considered delete all dashes and then parsing the field into 3
components and then adding the dashes back in but since some don't have area
codes using left/middle/right functions would screw up the 7 digit numbers.

There must be an easy way to remove just that last dash.

654-6541-
817-654-6541-
630-454-6541
751-6441
8756746551-
770-354-6546-
254-6241-


any ideas?

Z


0
Reply zaqq1111 1/22/2004 5:11:50 PM

<zaqq1111@yahoo.com> wrote:

> I have a list of phone numbers (7 & 10 digit) and many (but not all) of them
> have an extra dash "-" at the end of the number.  Is there anyway to delete
> just the last extra dash without deleting all? 
> There must be an easy way to remove just that last dash.
> 
> 654-6541-
> 817-654-6541-
> 630-454-6541

Leftwords(phone number, 4) will do this trick.

-- 
Hans Rijnbout
Utrecht, Netherlands
0
Reply jrijnb 1/22/2004 9:35:18 PM


jrijnb@xs4all.nl (Hans Rijnbout) wrote in message news:<1g7zh6o.69npx21vlvuh4N%jrijnb@xs4all.nl>...
> <zaqq1111@yahoo.com> wrote:
> 
> > I have a list of phone numbers (7 & 10 digit) and many (but not all) of them
> > have an extra dash "-" at the end of the number.  Is there anyway to delete
> > just the last extra dash without deleting all? 
> > There must be an easy way to remove just that last dash.
> > 
> > 654-6541-
> > 817-654-6541-
> > 630-454-6541
> 
> Leftwords(phone number, 4) will do this trick.

That may work for this data, but I don't like relying on the "word"
functions. Who knows what data will be in there and mess it up?
Consider the following:

case(
right(phone number,1) = "-",                       'is the rightmost
character a "-" ?
left(phone number, length(phone number) - 1),  'if it is, remove the
rightmost char
phone number                                                   
'otherwise, leave it alone
)

Use the replace menu command, but do yourself and me a favor and do it
on a backup file in case I wrote it wrong.
0
Reply paul 1/23/2004 1:34:37 PM

2 Replies
2145 Views

(page loaded in 0.13 seconds)

Similiar Articles:













7/24/2012 7:09:51 AM


Reply: