I tried replace found text recursively but i cant get it working. This will replace only 1 ´a´ char before each ´text´ but i want replace all ´a´ characters before text
//Declared recursive function
function OneLine(s:WideString):WideString;
begin
s:=StringReplace(s,'atext', 'text', [rfReplaceAll]);
if (Pos(Result,'atext')>0) then
begin
//XMLstring:=Result;
s:=OneLine(XMLstring);
end
else
begin
Result:=XMLstring;
end;
end;
//--Here begins program
Var
t:string
Begin
//exaple of text
//we need replace all 'a' before 'text' only
t:='aaHaaatextaaaatextHHaatextHHaaaa';
//call custom recursive function
t:=OneLine(t);
ShowMessage(t);
End.
I need replace this: 'aaHaaatextaaaatextHHaatextHHaaaa'
final text should looks like this: 'aaHtexttextHHtextHHaaaa'
Pos
, the first argument is the string you're searching for. Then put a breakpoint on the same line and examine what doesResult
hold when the breakpoint is hit. – Sertac Akyuz Jul 3 at 17:57