Replace
Добавлено: 25 май 2019, 08:28
Посмотрел, что в инструкции к спектракалку Вы жалуетесь, что он медленно работает с пробелами. Заглянул в функцию.
Вот это вот все:
должно выглядеть так:
Оу, я не сразу заметил, что Вы сами написали replace_string... Циклом... С конкатенациями множественными...
Посмотрите https://learn.javascript.ru/regular-exp ... javascript - обязательно пригодится. Остальные replace_string() тоже можно заменить на стандартную функцию. Работает везде и давно.
Вот это вот все:
Код: Выделить всё
function input_replace(){
spct_Ugly = spct;
spct = replace_string(spct,' ','\t');
spct = replace_string(spct,' ','\t');
spct = replace_string(spct,' ','\t');
spct = replace_string(spct,' ','\t');
spct = replace_string(spct,' ','\t');
spct = replace_string(spct,' ','\t');
spct = replace_string(spct,' \t','\t');
spct = replace_string(spct,' \n','\n'); //argyll
spct = replace_string(spct,'\t ','\t');
spct = replace_string(spct,'\t\t\t\t\t\t\t','\t');
spct = replace_string(spct,'\t\t\t\t\t\t','\t');
spct = replace_string(spct,'\t\t\t\t\t','\t');
spct = replace_string(spct,'\t\t\t\t','\t');
spct = replace_string(spct,'\t\t\t','\t');
spct = replace_string(spct,'\t\t','\t');
spct = replace_string(spct,'\n\n','\n');
spct = replace_string(spct,'\t\n','\n');
spct = replace_string(spct,'\n\t','\n');
spct = replace_string(spct,',','.');
spct = replace_string(spct,'"',''); //PO
spct = replace_string(spct,'\t\r','\r'); //Opera, IE
spct = replace_string(spct,'\r\t','\r'); //Opera, IE
spct = replace_string(spct,'\r\r','\r'); //Opera, IE
spctOK = spct;
}
Код: Выделить всё
function input_replace(){
spct_Ugly = spct;
spctOK = spct.replace(//[\t ]+/g/g, '\t').replace(/\s+/g, '\n').replace(/,/g, '.').replace(/\"/g, '');
}
Посмотрите https://learn.javascript.ru/regular-exp ... javascript - обязательно пригодится. Остальные replace_string() тоже можно заменить на стандартную функцию. Работает везде и давно.