// Add spaces after punctuation marks - ! ? ; . ,
// Made by Bedazzle, 2011.09.25
program AddSpacesAfterPunctuation;
// ---------------------------------------------
const
CRLF = ''#13''#10;
var
n, i : Integer;
txt : String;
// ---------------------------------------------
function ReplaceAll(t, s, r : String): String;
var
p : Integer;
begin
Result := '';
p := pos(s, t);
while p > 0 do
begin
Result := Result + copy(t, 1, p-1) + r;
t := copy(t, p+length(s), length(t)-p-length(s)+1);
p := pos(s, t);
end;
Result := Result + t;
end;
// ---------------------------------------------
function TrimLines(t : String): String;
var
p : Integer;
begin
Result := '';
p := pos(CRLF, t);
while p > 0 do
begin
Result := Result + trim(copy(t, 1, p-1)) + CRLF;
t := copy(t, p+length(CRLF), length(t)-p-length(CRLF)+1);
p := pos(CRLF, t);
end;
Result := Result + trim(t);
end;
// ---------------------------------------------
begin
n := GetSubtitleCount;
for i := 0 to n-1 do
begin
txt := GetSubtitleText(i);
txt := ReplaceAll(txt, '?', '? ');
txt := ReplaceAll(txt, '!', '! ');
txt := ReplaceAll(txt, ',', ', ');
txt := ReplaceAll(txt, '.', '. ');
txt := ReplaceAll(txt, ';', '; ');
txt := ReplaceAll(txt, '. . . ', '... ');
txt := ReplaceAll(txt, ' ', ' ');
txt := TrimLines(txt);
SetSubtitleText(i, txt);
end;
end.
Страница 1 из 1
Добавление пробелов после выбранных символов
#1
Отправлено 25 Сентябрь 2011 - 23:37
Добавление пробелов после символов ! ? ; . ,
Страница 1 из 1

Вход
Регистрация
Помощь


Цитата