14-06-2017, 07:59 AM
14-06-2017, 10:23 AM
السلام عليكم
الوظيفة stringreplace
النتيجة
الوظيفة stringreplace
كود :
var
before, after : string;
begin
// Try to replace all occurrences of a or A to THE
before := 'This is a way to live A big life';
after := stringreplace(before, ' a ', ' THE ',
[rfReplaceAll, rfIgnoreCase]);
ShowMessage('Before = '+before);
ShowMessage('After = '+after);
end;النتيجة
كود :
Before = This is a way to live A big life
After = This is THE way to live THE big life14-06-2017, 11:37 AM
شكرا لك حاولت التعديل على ملف نصي ولم يفلح الامر الاسم موجود بالسطر التاسع
14-06-2017, 04:00 PM
هكذا
PHP كود :
procedure Replace(const FilePath, OldName, NewName: string);
var
SL: TStringList;
begin
SL := TStringList.Create;
try
SL.LoadFromFile(FilePath);
SL.Text := StringReplace(SL.Text, OldName, NewName, [rfReplaceAll, rfIgnoreCase]);
SL.SaveToFile(FilePath);
finally
SL.Free;
end;
{
Usage:
begin
Replace('File.txt', 'ahmad', 'mhmod');
end;
}
end;