So I have a question on efficiency and don't have a good way to test it.
Which of the below code segments would most efficiently replace multiple spaces with a single space?
OR
Any suggestions or comments would be great.
Thank you,
Which of the below code segments would most efficiently replace multiple spaces with a single space?
Code:
l-txt = TRIM(l-txt).
DO WHILE l-txt MATCHES "* *":
l-txt = REPLACE(l-txt, " ", " ").
END.
OR
Code:
l-txt = TRIM(l-txt).
DO WHILE LENGTH(l-txt) > l-idx:
IF SUBSTRING(l-txt,l-idx,2) = " "
THEN DO:
SUBSTRING(l-txt,l-idx,2) = " ".
NEXT.
END.
l-idx = l-idx + 1.
END.
Any suggestions or comments would be great.
Thank you,