Pages: 1
RSS
Export mail to a single line, how to export mail body to a single line
 
Hey,

I am trying to export the result of a regex to a text file on a single line, for example:

I have a mail with the body:

asd@
123
678
@ert

I have a manual filter with the "Export to file" option and in its template the regex:
%REGEXPTEXT="@@@(.*)@@@"

This would create in the text file the filter exports to 2 lines

123
678

I am trying to get it to export both lines on a single line and interpret the new line as a single space, the desired output would be:

123 678

How can this be done?

Thank you!
 
I'm not sure whether it wprks, but you could try:
%Wapped='%REGEXPTEXT="@@@(.*)@@@"'
__________________________________
I'm just a user of The Bat! I don't work for Ritlabs.
 
Unfortunately that did not work :(
Sample text:

@@@unuseful text@@@  
line1

line2
~~~unuseful text~~~

I process this with:

%REGEXPTEXT="@@@.*@@@..(.*)~~~.*~~~"

and the output is:

---------
line1

line2
---------

Tried with:
%Wapped='%REGEXPTEXT="@@@.*@@@..(.*)~~~.*~~~"'
but the text in the "Preview" window just disappeared, maybe the syntax is not correct?

tried %wapped="%REGEXPTEXT="@@@.*@@@..(.*)~~~.*~~~""
but I got: @@@.*@@@..(.*)~~~.*~~~""

tried %wapped=%REGEXPTEXT="@@@.*@@@..(.*)~~~.*~~~"
but got a blank output
 
<blush>
I meant %Wrapped in stead of %wapped
__________________________________
I'm just a user of The Bat! I don't work for Ritlabs.
 
Hey, Unfortunately no luck, adding %wrapped:

%Wapped='%REGEXPTEXT="@@@.*@@@..(.*)~~~.*~~~"'
or
%Wapped='%REGEXPTEXT="@@@.*@@@..(.*)~~~.*~~~"'

returns the exact same string as it did without %wrapped and:

%Wapped="%REGEXPTEXT="@@@.*@@@..(.*)~~~.*~~~""
returns:
=@@@.*@@@..(.*)~~~.*~~~""

Thanks for your help!
 
When looking at the data you give in the first message, you get the wanteed results with this template:
%SetPattRegExp='(.*)@\n(.*)\n(.*)\n@(.*)'%-
%RegExpBlindMatch='%Text'%-
%SubPatt='2' %SubPatt='3'
Adapt this to your real data.
__________________________________
I'm just a user of The Bat! I don't work for Ritlabs.
 
I get nothing (blank when attempting to use this :(

Thanks!
 
Give me real sample of the text you want to process and I'll see whether we can fix that.
My regexp worked on the text you gave as example:
-------------------
asd@
123
678
@ert
-------------------
But in your second post you gave me:
-------------------
@@@unuseful text@@@
line1

line2
~~~unuseful text~~~
-------------------
In the latter case the regexp should look like:"
%SetPattRegExp='(.*)@\n(.*)\n\n(.*)\n~(.*)'%-
%RegExpBlindMatch='%Text'%-
%SubPatt='2' %SubPatt='3'
Note that it's important to know whether the empty line between line1 and line2 is a real empty line or that it may contain a (number of) space(s).
My regexp supposes it's a real empty line.
__________________________________
I'm just a user of The Bat! I don't work for Ritlabs.
 
Sorry for not being more specific :(

Here is how some real text would look like:
-------
@@@ http://werwerwer


@@@

this part of the text might be on a single line, multiple lines separated

by

any number

of blank lines



~~~dsfsdfsdf~~~
-------
or:
-------

@@@http://asd.local/asdasdasd
@@@

hello asdasdaasd,

please notice sldjflsdjflksdf

10 X
sdfsdfsdfs



~~~sdfsdfsdf~~~
--------
or:
--------
@@@ http://ddddddddddddddddddd


@@@

sdfsdfsdfsdfsdf



~~~sdfsdfsdfsd~~~

Thanks!
 
Ouch, I'm afraid that it's a bit over my head to develop a regexp that does this properly.
What you basically need is a regexp that gets the text between your markers. That's the easy part, you had that by yourself.

Next thing would be a recursive template that deletes all intstances of empty lines, it needs to be recursive because you don't know how often those empty lines occur.

Final thing would be a recursive template that replaces all single instances of a line feed into a space, so everything is placed on a single line.

And I'm not that good in recursive templates. You might want to look at the macro library at http://www.silverstones.com/thebat/Library.html It has some good examples of recursive templates.
__________________________________
I'm just a user of The Bat! I don't work for Ritlabs.
 
Thank you for your efforts, unfortunately the recursive templates are gibberish to me :(

Fortunately I found another walkaround - I put in the  initial filter that creates this template:

------------
@@@ http://werwerwer


@@@

this part of the text might be on a single line, multiple lines separated

by

any number

of blank lines



~~~dsfsdfsdf~~~
--------------------
another line:
%organization=%REGEXPTEXT="whatever"
(whatever) - the original regex I use to parse the body

This way when exporting the message to the file (using a second manual filter) I have the %organization field holding all the text in one line :)
Pages: 1