Appending results from regex to a file

rupertshih

Client
Регистрация
13.09.2011
Сообщения
44
Благодарностей
1
Баллы
0
Hi

I got multiple matches after applying regex
I want to write all the results to a file but add a new line(empty line) after each result.
How do I do it?

ex

from regex:
---match # 0----
aaaaaa
---match # 1----
bbbbbb
---match # 2----
cccccc

to a file:
aaaaaa

bbbbbb

cccccc


Thanks
 
Регистрация
01.02.2011
Сообщения
99
Благодарностей
15
Баллы
0
If you need spaces you need to do another regex with a loop & a counter on your regex results txt.

Regex line from 1st regex results file match#0, append that line to a new file
Append another line to file with blank results, to get your space
Add +1 to your counter in the regex match# & loop thru results again
put the {-Counter.Get-|-count1-} in your regex macro so the regex does the lines in sequence.
{-RegExp.RegExp-|--|--|-{-Counter.Get-|-count1-}-}
 

rupertshih

Client
Регистрация
13.09.2011
Сообщения
44
Благодарностей
1
Баллы
0
I will try it

but number of matches returned from regex is different each time
then how do I know how many matches do I get from regex?

thanks
 

drvosjeca

Client
Регистрация
26.10.2011
Сообщения
512
Благодарностей
455
Баллы
63
you just need to make a loop and follow what @CaptainObvious said, to make it sure you are not overdoing it, you should add checker for first result.

So what would i do is next:

1. i would go and make temorary file from result i got with first regex
2. I would use get line from file and appendi it to new file (if you wana get this in order, then use counter)
3. append blank line to file
4. use check if temporary file exists (this is to make it sure not to run if it is done)
-if file exists go and loop back to step 2 in order to complete
-if file doesnt exist, die and finins


I hope this helps ;-)
 
Регистрация
01.02.2011
Сообщения
99
Благодарностей
15
Баллы
0
This macro will get you the number of lines in your first regex
{-File.CountOfStrings-|-\Resources\filename.txt-}

So you could use the execution results from this macro in your logic for the loop
 

rupertshih

Client
Регистрация
13.09.2011
Сообщения
44
Благодарностей
1
Баллы
0
Hi

thanks for the reply

I did another approach

I get one match at a time by using counter from the regex.
after that macro, I use a logic check if 'something is not equal to noting' != '', then return true and write to a file, if false, done.
so I do not have to write a template file and write into another file, taking too much time this way though, I think.

another question, is there any way to count number of characters in a string?

thanks
 

rupertshih

Client
Регистрация
13.09.2011
Сообщения
44
Благодарностей
1
Баллы
0
another question

every time, when doing logic check( like this 'it's a sentence' != '' ), there is a single quotation in a sentence, it returns nothing, no true nor false.
how do I do in this case to make it returns true though?

Thanks
 

Hungry Bulldozer

Moderator
Регистрация
12.01.2011
Сообщения
3 441
Благодарностей
834
Баллы
113
'{-JS.PrepString-|-dasdas'asdasd-}'!=''
 

rupertshih

Client
Регистрация
13.09.2011
Сообщения
44
Благодарностей
1
Баллы
0

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