Compare file in string with content of a txt file

  • Автор темы Автор темы cesario678
  • Дата начала Дата начала

cesario678

Client
Регистрация
10.03.2022
Сообщения
227
Реакции
13
Баллы
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?
 
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.
 
string myIP = project.Variables["myIP"].Value;
string txtIP = System.IO.File.ReadAllText("C:\Temp\IPfile.txt");
project.Variables["exists"].Value = txtIP.Contains(myIP).ToString();
 
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
 
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?
 
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.
 
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
 
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

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