Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace problem

Status
Not open for further replies.

myspiral

Technical User
Jun 11, 2004
17
0
0
CA
I need to replace all instances of Ave with Avenue, which I can do except for when it occurs at the end of the field.
If you do a simple replace(txt,'Ave','Avenue') it screws up Avenue ie AveAvenue. Any advice on how to accomplish this?
 
How about:
[tt]Right(Trim(strStreet), 3) = "Ave"[/tt]
 
how would I use this to replace though?
 
With a query, perhaps:
[tt]UPDATE tblCustomers SET tblCustomers.Street = Left([Street],Len([Street])-3) & " Avenue"
WHERE ((Right(Trim([Street]),3)="Ave"));[/tt]
 
There's always this
Code:
Replace(Replace(Replace(txt,"Avenue",Chr(6)),"Ave","Avenue"),Chr(6),"Avenue")

[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
A simpler way:
UPDATE ...
SET txt=replace(txt,'Ave','Avenue')
[!]WHERE txt Not Like '*Avenue*'[/!]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I am missing a point (as usual) Cave Street? Averna Road?
 
Remou

True enough

- Haversham Road
- Aveneda Drive
- AverageGuy Street

Needs a bit more thought to handle that stuff. Maybe
Code:
Replace(Replace(Replace(txt & " ","Avenue",Chr(6)),
        " Ave "," Avenue "),Chr(6),"Avenue")

[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
So then Ave at the end of the line = " Ave"?
 
No ... notice that I concatenated a " " to the end of the text (i.e. txt & " ") to deal with that.

[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
UPDATE ...
SET txt = Replace(txt,'Ave','Avenue')
WHERE ' ' & txt & ' ' Like '* Ave *'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top