Compare file in string with content of a txt file

cesario678

Client
Регистрация
10.03.2022
Сообщения
171
Благодарностей
12
Баллы
18
I'm having a problem. I have a txt file with 1000 lines of IP addresses. I would like to extract the IP address I am currently using from a string, and compare it with the 1000 addresses in the file without having to do it one by one. Doing it manually is taking too long. Is there a way to analyze all of them at once and compare them with the IP address in the string that I specify?
 

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 812
Благодарностей
1 187
Баллы
113
You can take all data from file and use Data ==> Text processing and make a regex from your ip address. Then check with if action if regex is empty. If empty, then ip does not exist. If not empty, then exist.
 

EtaLasquera

Client
Регистрация
02.01.2017
Сообщения
526
Благодарностей
112
Баллы
43
string myIP = project.Variables["myIP"].Value;
string txtIP = System.IO.File.ReadAllText("C:\Temp\IPfile.txt");
project.Variables["exists"].Value = txtIP.Contains(myIP).ToString();
 

cesario678

Client
Регистрация
10.03.2022
Сообщения
171
Благодарностей
12
Баллы
18
You can take all data from file and use Data ==> Text processing and make a regex from your ip address. Then check with if action if regex is empty. If empty, then ip does not exist. If not empty, then exist.
Could you help me with this model? I have no idea how to set up this file call, and have it go through this regex, I looked at Zennoposter and got confused on how to configure it
 

cesario678

Client
Регистрация
10.03.2022
Сообщения
171
Благодарностей
12
Баллы
18

cesario678

Client
Регистрация
10.03.2022
Сообщения
171
Благодарностей
12
Баллы
18
Você pode pegar todos os dados do arquivo e usar Dados ==> Processamento de texto e fazer um regex a partir do seu endereço IP. Em seguida, verifique com if action se o regex estiver vazio. Se estiver vazio, o ip não existe. Se não estiver vazio, então existe.
[/CITAR]
Hellooo
 

cesario678

Client
Регистрация
10.03.2022
Сообщения
171
Благодарностей
12
Баллы
18
You can take all data from file and use Data ==> Text processing and make a regex from your ip address. Then check with if action if regex is empty. If empty, then ip does not exist. If not empty, then exist.
From what I understood, this function you provided will process line by line, correct? Is there no way for it to read the entire file at once and check if it contains the same content as a specified variable?
 

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 812
Благодарностей
1 187
Баллы
113

cesario678

Client
Регистрация
10.03.2022
Сообщения
171
Благодарностей
12
Баллы
18

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 812
Благодарностей
1 187
Баллы
113
My suggestion use no any lists, therefore there are not any lines. This action Data ==> Files ==> Get text takes all data into one variable. After that you regex on the whole variable and get your result.
 

cesario678

Client
Регистрация
10.03.2022
Сообщения
171
Благодарностей
12
Баллы
18
Minha sugestão é não usar listas, portanto não há linhas. Esta ação Dados ==> Arquivos ==> Obter texto coloca todos os dados em uma variável. Depois disso, você regex em toda a variável e obtém seu resultado.
[/CITAR]
So I have no idea how to use regex, could you help me? Showing just a simple template of the fields as if it were analyzing a variable, in the template, sorry but I don't understand anything about programming, thank you
 

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 812
Благодарностей
1 187
Баллы
113
My suggestion: Use forum search and use terms like regex or regular expression and read through threads and learn how it works. Regex is an important thing to know, will save you lots of headaches if you will learn something from it.
 
  • Спасибо
Реакции: cesario678

EtaLasquera

Client
Регистрация
02.01.2017
Сообщения
526
Благодарностей
112
Баллы
43

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