如何遍历TRichEdit文本的所有可见字符?


 
var
  i: Integer;  
  c: Char;
  cord: Integer;
...
i := -1;
for c in RichEdit1.Text do
begin
  Inc(i);
  cord := ord(c);
  if (cord = 13) then
    Dec(i);
  if (cord >= 32) and (not ((cord > 126) and (cord < 161))) then
  begin
    // do your stuff here, for example exchanging red and green colors:
    RichEdit1.SelStart := i;
    RichEdit1.SelLength := 1;
    if RichEdit1.SelAttributes.Color = clGreen then
      RichEdit1.SelAttributes.Color := clRed
    else if RichEdit1.SelAttributes.Color = clRed then
      RichEdit1.SelAttributes.Color := clGreen;
  end;
end;


联系电话:
020-00000000
联系电话:
020-00000000
联系电话:
020-12345678