Witam,
mam problem z komponentem Richedit. Chcę automatycznie przeszukać cały tekst i do innego Richedit wypisać wszystkie wyrazy, które zawierają polskie litery (np. bąk itp.)? Może mi ktoś podpowiedzieć jak kopiować całość wyrazu zawierającego polskie czcionki?
Dzięki! :)
0
0
Można pewnie jakoś inaczej, ale ten sposób działa.
Sposób dodawania słow do drugiego RichEdit to już
samemu sobie dopasuj, jeżeli ma inaczej wyglądać.
Poza tym takie banalne pytania to w dziale Newbie.
//...
function HavePLChars(Text : string) : boolean;
const
PLChars = ['ą', 'ć', 'ę', 'ł', 'ń', 'ó', 'ś', 'ż', 'ź', 'Ą', 'Ć', 'Ę', 'Ł', 'Ń', 'Ó', 'Ś', 'Ż', 'Ź'];
var
I : integer;
OKChars : set of Char;
begin
Result := False;
OKChars := PLChars;
if Length(Text) = 0 then
begin
Exit;
end;
for I := 1 to Length(Text) do
begin
if (Text[I] in OKChars) = True then
begin
Result := True;
Break;
end;
end;
end;
function Explode(Str : string; Separator : string) : TStringList;
var
X : integer;
begin
Result := TStringList.Create;
X := Pos(Separator, Str);
while X > 0 do
begin
Result.Add(Copy(Str, 1, X - 1));
if X <= Length(Str) then
begin
Str := Copy(Str, X + Length(Separator), Length(Str));
end;
X := Pos(Separator, Str);
end;
if (Length(Str) > 0) then
begin
Result.Add(Str);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
S : string;
I : integer;
SL : TStringList;
begin
RichEdit2.Lines.Clear;
SL := Explode(RichEdit1.Text, ' ');
for I := 0 to SL.Count - 1 do
begin
S := SL[I];
if HavePLChars(S) = True then
begin
RichEdit2.Lines.Add(S);
end;
end;
SL.Free;
end;
0
Dzięki Wielkie! :)