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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to find certain characters at the end of a string and remove them

Status
Not open for further replies.

Seabz420

IS-IT--Management
Jul 14, 2003
129
CA
WinXP
CR 10

I need to search all the names in a report to find the ones that end with either " OR" or " AND". If there are some, then I need to remove that part of the name. The I'm having problems with the fact that all the names are different lengths so how do I say, go to the end of the field and then back 3 spaces and if that text is " or" then remove it. Else go back 4 spaces and if that text is " and" then remove that!?
 
Try:

if right(trim({table.field}),3) = " OR" or
right(trim({table.field}),4) = " AND" then
left(trim({table.field}),instrrev({table.field}," ")-1)

-LB
 
Thanks! I did some searching and manage to frankenstien a formula together...eerily very similar to yours!

if right({DEPLN.TITLE1},3)=" OR" then
replace({DEPLN.TITLE1},right({DEPLN.TITLE1},3)," ") else
if right({DEPLN.TITLE1},4)=" AND" then
replace({DEPLN.TITLE1},right({DEPLN.TITLE1},4)," ") else
{DEPLN.TITLE1}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top