0
我想有一個功能,發送字符串替換的oripart
多次出現,以newpart
:更換子多次出現在紅語言
strReplace: func [str [string!] oripart [string!] newpart [string!]][
if find str oripart [
change find str oripart newpart
strReplace str oripart newpart ] ; recursion to change more occurrences;
str ]
print strReplace "this is a short line" "short" "small"
print strReplace "this is a short line" "this" "THIS"
print strReplace "this is a short line" "line" "LINE"
print strReplace "this is a long line" "short" "small"
print strReplace "this is a short short line" "short" "small"
我使用遞歸刪除多次出現。它適用於單一測試線。但是,如果我正在測試代碼,它會產生堆棧溢出。哪裏有問題?
之後在一個位置遞減遞減是的,發現/案例是真正的問題。 – rnso
改爲使用** replace/all **,因爲它會取代所有的出現 – sqlab