Link to home
Start Free TrialLog in
Avatar of RVL
RVL

asked on

replace a word

Hi
we would like to replace the word TYPE with '' in a column called HOLD
ASKER CERTIFIED SOLUTION
Avatar of peterhupp
peterhupp
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Pavel Celba
I would guess RVL needs to replace this word by empty string not by apostrophs, so:

REPLACE hold WITH STRTRAN(hold,'TYPE','') FOR "TYPE" $ hold

Such replacement will replace ALL occurences, so words having TYPE substring inside will be damaged...

Better version could be:

REPLACE hold WITH LTRIM(STRTRAN(" " + hold + " "," TYPE "," ")) FOR " TYPE " $ " " + hold + " "
or case insensitive variant:
REPLACE hold WITH LTRIM(STRTRAN(" " + hold + " "," TYPE "," ", 1, -1, 1)) FOR " TYPE " $ " " + UPPER(hold) + " "

But the TYPE word can be followed by comma, point, or other separators now and not all occurences will be replaced...