REBOL.net

Re: Stuck on Parse - Need Help

Curley Simon (jonwhispa)
5-Aug-2008/15:10:29-4:00
#44172
<Back   Thread   Next>
<Back   Index   Next>

Hi,

The first "thru" would match and the parsing would end and go back to "any"
then matching the first "thru" again and again.
You just needed to remove the "thru"`s and add a "skip" at the end to pass
over any extra text

out-file: to-file "arq.txt"
parse corpo [
    any [
        "Evento:" copy evt to newline (write/append out-file rejoin
["------" newline evt newline])  |
        "Início:" copy ini to newline (write/append out-file rejoin [ini
newline])  |
        "Fim:" copy fim to newline (write/append out-file rejoin [fim
newline])  |
         skip
    ]
]


Slightly different version than the others, with a single write.

out-text: ""
output: [ copy temp thru newline (append out-text trim temp) ]
parse/all corpo [ any [ "Evento:" (append out-text "--------^/") output |
"Início:" output | "Fim:"  output | skip ] ]
;write to-file "arq.txt" out-text
print out-text

--------
Boxe - Preliminares
09/08/2008 02:30
09/08/2008 05:45
--------
Handebol Masculino
09/08/2008 22:00
09/08/2008 23:00
--------
Vôlei de Praia - Masc.
09/08/2008 23:00
10/08/2008 00:00

Jon

2008/8/5 Carlos Lorenz <carlos.lorenz-gmail.com>

> Hi list,
>
> I would appreciate some help on this parse matter.
>
> I have the following string:
>
> corpo: {
>
> Evento: Boxe - Preliminares
> Início: 09/08/2008 02:30
> Fim: 09/08/2008 05:45
> Sinopse: Acompanhe ao vivo as preliminares do boxe, categoria médio (até
> 75kg), direto do Ginásio dos Trabalhadores.
>
> Evento: Handebol Masculino
> Início: 09/08/2008 22:00
> Fim: 09/08/2008 23:00
> Sinopse: Acompanhe ao vivo a estréia de Croácia x Espanha no torneio
> masculino, em jogo válido pelo Grupo A, direto do Ginásio do Centro
> Olímpico.
>
> Evento: Vôlei de Praia - Masc.
> Início: 09/08/2008 23:00
> Fim: 10/08/2008 00:00
> Sinopse: Xu e Wu, da China, Gosch e Horst, da Áustria, disputam, nas areias
> da Arena de Vôlei de Praia, o jogo válido pela 1Ş rodada do Grupo A.
> }
>
>
> And I need to have some data out of the string written on a file like this:
>
> ------
> Boxe - Preliminares
> 09/08/2008 02:30
> 09/08/2008 05:45
> ------
> Handebol Masculino
> 09/08/2008 22:00
>  09/08/2008 23:00
> ------
> Vôlei de Praia - Masc.
> 09/08/2008 23:00
> 10/08/2008 00:00
>
>
> Here is the code I am trying to run with no success:
>
>
> REBOL[]
>
> corpo: {
>
> Evento: Boxe - Preliminares
> Início: 09/08/2008 02:30
> Fim: 09/08/2008 05:45
> Sinopse: Acompanhe ao vivo as preliminares do boxe, categoria médio (até
> 75kg), direto do Ginásio dos Trabalhadores.
>
> Evento: Handebol Masculino
> Início: 09/08/2008 22:00
> Fim: 09/08/2008 23:00
> Sinopse: Acompanhe ao vivo a estréia de Croácia x Espanha no torneio
> masculino, em jogo válido pelo Grupo A, direto do Ginásio do Centro
> Olímpico.
>
> Evento: Vôlei de Praia - Masc.
> Início: 09/08/2008 23:00
> Fim: 10/08/2008 00:00
> Sinopse: Xu e Wu, da China, Gosch e Horst, da Áustria, disputam, nas areias
> da Arena de Vôlei de Praia, o jogo válido pela 1Ş rodada do Grupo A.
> }
>
> out-file: to-file "arq.txt"
>
> parse corpo [
>
>                    any
>
>                        [
>
>                           thru "Evento:" copy evt to newline (write/append
> out-file rejoin ["------" newline evt newline])  |
>                           thru "Início:" copy ini to newline (write/append
> out-file rejoin [ini newline])  |
>                           thru "Fim:" copy fim to newline (write/append
> out-file rejoin [fim newline])  |
>
>                         ]
>
>                           to end
>
>                   ]
>
>
> Thanks for any help
>
> --
> Carlos Lorenz
>
> --
> To unsubscribe from the list, just send an email to
> lists at rebol.com with unsubscribe as the subject.
>
>



<Back   Thread   Next>
<Back   Index   Next>

REBOL.com