Parse delimiter separated usernames and passwords from .txt using regex.

qotsa

Client
Регистрация
01.05.2011
Сообщения
4
Благодарностей
0
Баллы
0
Hi, I've been trying to work this out but I'm finding it hard to get a solution.
What I'm trying to do is:
Use regex to parse a txt in the format username|password|irrelevant stuff|more irrelevance stuff|etc||||
I need one regex string to parse the username and another to parse the password.
I'm going to be using it in Zennoposter so that I can enter a username into a form and use the corresponding password. After this the line from the txt will be deleted to start on the next account.
Would appreciate any help, cheers!
 

Hungry Bulldozer

Moderator
Регистрация
12.01.2011
Сообщения
3 441
Благодарностей
831
Баллы
113
You don't need regexp for this task. You had better take a line from file using File.GetString macro
and then take execution result of this branch and first take username using {-String.Split-|-LINE-|-|-|-0-}
This macro take first value - username, to take password use {-String.Split-|-LINE-|-|-|-1-}
 
  • Спасибо
Реакции: qotsa

qotsa

Client
Регистрация
01.05.2011
Сообщения
4
Благодарностей
0
Баллы
0
Never mind, I found the solution.

Using 'Files and Directories' => 'Take a Line from the File' I used .*?(?=\|) as the regex for the field 'Regular Expression to Parse Selected Line(s)'.
For the first result (username) I entered 0 as the value in the field 'Number of Match after Parsing with Regular Expression' and for the second value (password) I entered 2.

{-File.GetString-|-\Templates\YOURTXT.txt-|-0-|-false-|-.*?(?=\|)-|-0-} for username.
{-File.GetString-|-\Templates\YOURTXT.txt-|-0-|-false-|-.*?(?=\|)-|-2-} for password.

If you use a different delimiter such as : you would change .*?(?=\|) to .*?(?=\:-)
 

qotsa

Client
Регистрация
01.05.2011
Сообщения
4
Благодарностей
0
Баллы
0
You don't need regexp for this task. You had better take a line from file using File.GetString macro
and then take execution result of this branch and first take username using {-String.Split-|-LINE-|-|-|-0-}
This macro take first value - username, to take password use {-String.Split-|-LINE-|-|-|-1-}
Wow, thanks for the fast reply!
That seems like a better solution, cheers :D
 

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