lundi 29 janvier 2001

Comment chercher et remplacer des caractères?

Comment chercher et remplacer des caractères?
function SearchAndReplace
  (sSrc, sLookFor, sReplaceWith : string) : string;
var
  nPos, nLenLookFor : integer;
begin
  nPos        := Pos(sLookFor, sSrc);
  nLenLookFor := Length(sLookFor);
  while (nPos > 0) do begin
    Delete(sSrc, nPos, nLenLookFor);
    Insert(sReplaceWith, sSrc, nPos);
    nPos := Pos(sLookFor, sSrc);
  end;
  Result := sSrc;
end;

Aucun commentaire:

Enregistrer un commentaire

Comment les annotations façonnent le code en Java

  Introduction : L'évolution de la métaprogrammation en Java Traditionnellement, l'i...