‎2007 Jul 03 1:46 PM
Hi,
I'm searching for a possibility to replace complete words inside a string.
For example I want to replace "quick" by "slow":
"The <b>quick</b> brown fox is running quicker then the slow brown fox".
The result shall be:
"The <b>slow</b> brown fox is running quicker then the slow brown fox".
The problem is, that the built in "Replace"-Method would also replace "quicker" by "browner".
Furthermore, words beetween different signs (e.g. , . ; : - ! " ? ') shall also be found as complete word.
I already searched for a FM but didn't find anything. Regular expressesions are also not possible because we are running on 6.40.
Maybe anybody can help me with a simple FM or something else.
Best regards,
Stefan
‎2007 Jul 03 1:54 PM
‎2007 Jul 03 1:56 PM
Hi Ashvender,
as far as I know this would also replace all substrings, or not!?
Stefan
‎2007 Jul 03 1:56 PM
‎2007 Jul 03 1:58 PM
Hi Sesh,
that would work. But if there does occur another sign (such as quotes) it wouldn't work...
Stefan
‎2007 Jul 03 2:02 PM
Hi,
Then may be you can to execute multiple REPLACE statements.
I know its crude but I think no option.
Also may be you can split your string at SPACE and then
execute REPLACE in table.
Regards,
Sesh
‎2007 Jul 03 2:01 PM
Hi,
Give the line in one string
IF string CN 'quick'.
REPLACE 'quick' WITH 'sloa' INTO field.
ENDIF.
Regards,
Nandha
Reward if it helps
‎2007 Jul 03 2:01 PM
Hi Stefan,
There is a crude way of doing this....with lots of loops..
You can use the SPLIT statement
SPLIT dobj AT sep INTO
{ {result1 result2 ...} | {TABLE result_tab} }
[IN {CHARACTER|BYTE} MODE].
and break the sentence into words using space as delimiter. Once you have all the words in a internal table, you can loop through it and compare each word with the word you want.
This will solve the problem, but will not be performant enough.
Regards,
Vinodh
‎2007 Jul 03 2:01 PM
Hi,
your not replacing 'quick' your replacing ' quick '.
see this:
*----
REPORT ZEND_TEST14 MESSAGE-ID zrsp.
data: l_string type string value 'The quick brown fox is running quicker then the slow brown fox'..
replace ' quick ' in l_string with ' slow '.
write l_string.
*----
Steffen
‎2007 Jul 03 2:24 PM
Use
REPLACE <'FIND TEXT'> IN <COMPLETE SEMNTENCE> WITH <'REPLACED TEXT'>.
or
replace all occurances of '.' with ''.
or
REPLACE '.' WITH ' ' INTO in_par-value.
or
var1 = '4444/33'.
REPLACE '/' with SPACE in var1.
Condense var1 no-gaps.
Rewards if useful.
‎2007 Jul 05 6:39 AM
Hi everybody,
I have played around with different possibilities but nothing seems to be really good. Insertion of space before and after the search-term is not possible because of many other signs which can precede or follow.
I think the only one solution at this time would be to try the different combinations of the "special signs" in combination with the word - but this could slow down the whole application.
I decided not to offer the possibility to replace whole words. Only simple replacements with "REPLACE" will be possible.
Best regards,
Stefan