Ir al contenido


Foto

[TRUCO DELPHI] Buscar y Reemplazar [OLD DELPHIs]


  • Por favor identifícate para responder
No hay respuestas en este tema

#1 sir.dev.a.lot

sir.dev.a.lot

    Advanced Member

  • Miembros
  • PipPipPip
  • 545 mensajes
  • Location127.0.0.1

Escrito 28 noviembre 2016 - 02:46

[TRUCO DELPHI] Buscar y Reemplazar [OLD DELPHIs]


delphi
  1. function SearchAndReplace
  2. (sSrc, sLookFor, sReplaceWith : string) : string;
  3. var
  4. nPos, nLenLookFor : integer;
  5. begin
  6. nPos := Pos(sLookFor, sSrc);
  7. nLenLookFor := Length(sLookFor);
  8. while (nPos > 0) do begin
  9. Delete(sSrc, nPos, nLenLookFor);
  10. Insert(sReplaceWith, sSrc, nPos);
  11. nPos := Pos(sLookFor, sSrc);
  12. end;
  13. Result := sSrc;
  14. end;

Saludos!


  • 1




IP.Board spam blocked by CleanTalk.