parsing text????
[1/3] from: akhar::videotron::ca at: 24-Aug-2000 22:26
I have the following text
dog.eat.dog.eat.cat.eat.fish
dog.eat.dog.eat.cat.eat.fish?but no
dog.eat.dog.eat.cat.eat.fish"really
dog.eat.dog.eat.cat.eat.fish
dog.eat.dog.eat.cat.eat.fish"mmmm
dog.eat.dog.eat.cat.eat.fish
and am using the following code to parse it:
html-code: [
thru newline copy url to {?|"|newline} (append urls url) |
copy txt to newline (append text txt)
]
page: read %emails.txt
parse page [ to newline copy url some html-code (append urls url) ]
it freezes I tried many combination but just cannot get the whole txt only
parts at the time or parts of the original file.
help
Stephane
[2/3] from: chris:ross-gill at: 25-Aug-2000 12:45
Hi Stephane,
> I have the following text
> dog.eat.dog.eat.cat.eat.fish
<<quoted lines omitted: 14>>
> help
> Stephane
How about:
page: read/lines %emails.txt
text: copy []
urls: copy []
;an just stands for alphanumeric
an-chars: charset [#"a" - #"z"] ;add more, this is a simple example
an-text: [some an-chars]
an-url: [an-text some ["." an-text]]
rule: [
copy url an-url (append urls url) any [
["?" | {"}] copy txt an-txt (append text txt)
]
]
foreach line page [parse line rule]
I'm not sure if this entirely addresses your question.
- Chris
[3/3] from: jelinem1:nationwide at: 25-Aug-2000 8:53
First, unless you know something I don't (very possible) I don't think the
following is correct:
copy url to {?|"|newline}
This will look for the string '?|"|newline' in the file. I think what you
really wanted was:
copy url [ to "?"| to {"}| to newline]
Unfortunately this won't work and is my biggest pet peeve with 'parse. What
*I* expect this to do is to look for the first occurrance of "?" OR {"} OR
newline, WHICHEVER COMES FIRST. What this actually does is to look for an
occurrance of "?" in the file. If the ENTIRE FILE does not contain "?" then
it looks for an {"}. Again, if the ENTIRE FILE does not contain {"} then it
looks for newline. Is this bevavior useful in anybody's case? I guess it
could be, but I haven't run into it yet.
If your data does not contain "?" or {"} then you can use your code but
you'll have to process a line at a time. Instead of searching the entire
file for one of these chars, it will only search the entire current line.
Either that, or rewrite your code NOT to use 'parse. NOTE: You might be
able to do something with 'charset but I haven't played with enough to know
for sure.
- Michael Jelinek
[akhar--videotron--ca] on 08/24/2000 09:26:10 PM
From: [akhar--videotron--ca] on 08/24/2000 09:26 PM
Please respond to [list--rebol--com]
To: [list--rebol--com]
cc:
Subject: [REBOL] parsing text????
I have the following text
dog.eat.dog.eat.cat.eat.fish
dog.eat.dog.eat.cat.eat.fish?but no
dog.eat.dog.eat.cat.eat.fish"really
dog.eat.dog.eat.cat.eat.fish
dog.eat.dog.eat.cat.eat.fish"mmmm
dog.eat.dog.eat.cat.eat.fish
and am using the following code to parse it:
html-code: [
thru newline copy url to {?|"|newline} (append urls url) |
copy txt to newline (append text txt)
]
page: read %emails.txt
parse page [ to newline copy url some html-code (append urls url) ]
it freezes I tried many combination but just cannot get the whole txt only
parts at the time or parts of the original file.
help
Stephane
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted