Trying to mass find/replace regex in a list

nycdude

Пользователь
Регистрация
06.05.2018
Сообщения
57
Благодарностей
1
Баллы
8
Hello all,

Sorry to ask so many questions here in the forum, you guys are helpful and I really appreciate it.

I'm trying to do mass edits and clean ups in a list with regex, doing it line by line with action blocks is too much and too slow. I'm trying to use this code here: https://zennolab.com/discussion/threads/search-in-list-and-tables-via-c-macro.10733/

...but it's not working. I can sort of read C# and it looks ok I think, but it's not working:
Код:
var parserRegexPattern = project.Variables["(?<=>).*?(?=</p>)"].Value;
var parserRegex = new System.Text.RegularExpressions.Regex(parserRegexPattern);
// get a list for searching
var sourceList = project.Lists["paragraphStripping"];
// get result list
var destList = project.Lists["article"];
// search in each line of the list
lock(SyncObjects.ListSyncer)
{
    for(int i=0; i < sourceList.Count; i++)
    {
        // take one line from the list
        var str = sourceList[i];
        // check the line on matches by regex, if there are matches we put it to result list
        if (parserRegex.IsMatch(str))
        {
            destList.Add(str);       
        }
    }
}
Anyone can make heads or tails of this? Honestly speaking, the list and table action blocks should have more ways to manipulate selected (or all) lines for mass regex edits.
 

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 805
Благодарностей
1 187
Баллы
113
Hi. Speed in PM and Zenno will be different.
Try testing your needs in zennoposter and see if thats okay.

Also You can disable drawing there and it will debug much faster in PM as well.

 
  • Спасибо
Реакции: nycdude

EtaLasquera

Client
Регистрация
02.01.2017
Сообщения
526
Благодарностей
112
Баллы
43
There is not great diference working a compile project with blocks or with c# code.
As lokiys say's, click in box "delayed drawing" :-)
 

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)