Добавил еще ведущие нули к миллисекундам, если кому-то еще когда-то этот код понадобится
log = function (text, color, define){ var id, time, thread, logHtml, textLog; define = (typeof define == 'string') ? define.split(/[\s,.|:;]+/g) : define; if(typeof define === 'object' && define !== null){ if(Array.isArray(define)){ id = define.indexOf('id') > -1; time = define.indexOf('time') > -1; thread = define.indexOf('thread') > -1; } else{ id = define.id == true; time = define.time == true; thread = define.thread == true; } } else id = time = thread = true; id = id ? '<a href="action://action' + ScriptWorker.GetCurrentAction() + '" style="color:gray;">[' + ScriptWorker.GetCurrentAction() + ']</a>' : ''; time = time ? ' ' + getTime() : ''; thread = thread ? ' Поток №' + thread_number() : ''; logHtml = (id || time || thread) ? id + '<span style="color: white">' + time + thread + ' : </span>' : ''; logHtml += '<span style="color:' + (color ? color : 'white') + '">' + text + '</span>'; textLog = '[' + ScriptWorker.GetCurrentAction() + ']' + time + thread + ' : ' + text function getTime(){ var checkTime = function(i){ return (i < 10) ? "0" + i : i; }; var checkMilliSeconds = function(ms){ if (ms < 10) { return "00" + ms; } else if (ms < 100) { return "0" + ms; } else { return ms; } }; var d = new Date(); var hh = checkTime(d.getHours()); var mm = checkTime(d.getMinutes()); var ss = checkTime(d.getSeconds()); var ms = checkMilliSeconds(d.getMilliseconds()); return '[' + hh + ':' + mm + ':' + ss + '.' + ms + ']'; }; Logger.WriteHtml(logHtml, textLog); }Как удалить лишние пробелы (88 штук) в тексте в процессе парсинга?
-
Здравствуйте!
При парсинге есть переменная - которая считывает телефон + емайл в одну целую переменную...
Разделитель там везде одинаковый - какое-то конкретное количество пробелов.
Вот пример:7-863-2700885 sparpachin@gmail.com 7-812-3345229 tender@mcp-bbraun.ru (4852) 49-33-43 rx3mz@mail.ru 7-812-4251818 info@klinoff.com 8-863-2700885 avd_14@bk.ru 7-863-2483266 foods.opt@bk.ru 7-4012-957933 aleksey.baev.kld@gmail.com 7-863-2006817 tender@myasnoff.net 7-812-3131125 info@rusarsenal-spb.ru 8 (84235) 4-56-50 resurs-tranzit@bk.ru +7 (347) 256 38 38 tekhnomed.z@mail.ru 7-863-2006817 Tender@myasnoff.net 8-495-6899715 Licom 07@mail.ru 8-632-3011040 edoav@yandex.ru 7-4922-474114 KSB9107722941@gmail.com 7-4932-328701 nvkom@bk.ru 7-812-7770473 maximus-as@yandex.ru 8-812-7401614 mail@1gazk.ru 7-812-4506765 jks_petergof@mail.ru 8-38557-51850 karat98@yandex.ruЯ вообще там насчитал 88 пробелов (вроде как).
Вопрос в том - как мне эти пробелы заменить на табуляцию? Возможно ли это сделать в режиме "онлайн" - когда работает парсер?
-
Выполнить код
[VAR] = [VAR].replace(/\s+/g, ' ') -
@brotok если не понимаете как использовать решение @artSamDev , можете использовать стандартное действие "Заменить строку":

