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

Replace, Strip or Remove Text from a field 1

Status
Not open for further replies.

product26

IS-IT--Management
Sep 27, 2007
26
US
Hello,

We have a field in our database which contains a formatted paragraph of text for each entry. I need to remove the formatting code from the field and list only the text. I have a list of all of the possible code to be removed, but I cannot get crystal to actually remove it.

I tried the replace function, but when I insert multiple replace functions it only processes the last one in the formula. for example, if the formula were:

REPLACE({orders.adtext},"[f4pc8fbya]","<B>");
REPLACE({orders.adtext},"[f4pc8ya]"," ");
REPLACE({orders.adtext},"[f4pc8s6.5]"," ");
REPLACE({orders.adtext},"[bs0,2,4]"," ")

it would only replace [bs0,2,4]with a space.

any suggestions?
 
Yes, the formulas are working correctly. You have to remember that a formula in Crystal works a lot like a function. If you want all those actions to take place then you need to set up a variable and assign the replace statements to that variable (i.e.
stringvar resultstr;
resultstr := REPLACE({orders.adtext},"[f4pc8fbya]","<B>");
resultstr :=REPLACE(resultstr,"[f4pc8ya]"," ");
resultstr :=REPLACE(resultstr,"[f4pc8s6.5]"," ");
resultstr :=REPLACE(resultstr,"[bs0,2,4]"," ");
resutlstr;

I hope this helps.
 
Hi Product26

You could also avoid the use of variables by using nested REPLACE functions, as follows:

REPLACE(REPLACE(REPLACE(REPLACE({orders.adtext},"[f4pc8fbya]","<B>"), "[f4pc8ya]"," "), "[f4pc8s6.5]"," "), "[bs0,2,4]"," ")

Cheers,
Pete
 
pmax9999 your suggestion worked perfectly!
THANKS!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top