Removing characters from a text

Asked

Viewed 1,613 times

-1

Hello, I need to make an application that within a notepad (which I did), remove data in an interval. What I need now is to know how to remove the email (in parentheses) from the phrase.
Example:

From: João de Almeída <[email protected]>
To: John of Almeida

Does anyone know how to do or give a hint? Note: They are several names followed with email.

2 answers

1


See if this is what you want to do!!

procedure TForm1.Button1Click(Sender: TObject);
 var p1, p2 : Integer; linha : String;
begin
   linha := 'De: João de Almeída <[email protected]>';
   ShowMessage('Antes: '+ linha );
   p1 := pos('<', linha );
   p2 := pos('>', linha );
   Delete( linha, p1, p2);
  ShowMessage('Depois: '+ linha );
end;
  • thanks but I’ve already solved :D

  • @Wederson , Please put your solution in your question and analyze if the answer fits as a solution to your problem.

-1

Follows solution to the problem...

procedure TfrmPrincipal.RemoverEmailJackson;
var
  vTexto: string;
  vTextoAux: TStringList;
  i: Integer;
begin
  try
    vTextoAux := TStringList.Create;
    vTexto := trim(Frmtexto.Memo1.Text);
    while length(vTexto) <> 0 do
    begin
      vTextoAux.Add(trim(Copy(vTexto, 0, pos('<', vTexto) - 1)));
      Delete(vTexto, 1, pos('>', vTexto) + 1);
    end;

    vTextoAux.Sort;
    Frmtexto.Memo1.Text := vTextoAux.Text;
  finally
    FreeAndNil(vTextoAux);
  end;
end;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.