[Gambas-user] Mystery with file.load and regexp

Fernando Cabral fernandojosecabral at ...626...
Wed Jul 5 04:28:40 CEST 2017


I have found and worked around the problem. When you do the following:

*Dim Expressions as string[] =
Split(File.Load("/home/fernando/.config/libreoffice/4/user/basic/indesejaveis.txt"),
"\n") *

The last item pushed into *Expressions* is an empty string ("") even though
it DOES NOT exist
in the file. So, the expressions are compiled one after the other til the
last one, that is empty. Then the program crashes.

So it seems there is a bug in the *load.file()*. Bug that I was able to
compensate for by adding the option *True* in the call to the functions
*split()*.

2017-07-04 22:29 GMT-03:00 Fernando Cabral <fernandojosecabral at ...626...>:

> Concerning RegExp I have another mysterious thing to understand
>
> If I do something like:
>
>
>
>
>
>
>
>
> *Searchfor.Push("Word")Searchfor.Push("Power")Searchfor.Push("The
> same")For Each searchedfor In searchfor   re.Compile(searchedfor,
> re.utf8)Next*
> The expression gest compiled. No error.
> Neverthelesse, if I the same words from a file, using this expression:
>
> *Dim Searchfor As New String[] = Split(File.Load("Strings"), "\n")*
>
> re.Compile will not work. It will display an error message saying there is
> nothing to compile. Now, if I do:
>
>
> *print "@" & Searchfor[n] &"@\n"*
> in both cases I will see precisely the same output. I can't distinguish
> one from the other. So, why it compiles in the first case, but does not in
> the second?
>
> This is the mystery I must solve with a little help from a good soul out
> there.
>
> - fernando
>
>
>
> --
> Fernando Cabral
> Blogue: http://fernandocabral.org
> Twitter: http://twitter.com/fjcabral
> e-mail: fernandojosecabral at ...626...
> Facebook: f at ...3654...
> Telegram: +55 (37) 99988-8868 <(37)%2099988-8868>
> Wickr ID: fernandocabral
> WhatsApp: +55 (37) 99988-8868 <(37)%2099988-8868>
> Skype:  fernandojosecabral
> Telefone fixo: +55 (37) 3521-2183 <(37)%203521-2183>
> Telefone celular: +55 (37) 99988-8868 <(37)%2099988-8868>
>
> Enquanto houver no mundo uma só pessoa sem casa ou sem alimentos,
> nenhum político ou cientista poderá se gabar de nada.
>
>


-- 
Fernando Cabral
Blogue: http://fernandocabral.org
Twitter: http://twitter.com/fjcabral
e-mail: fernandojosecabral at ...626...
Facebook: f at ...3654...
Telegram: +55 (37) 99988-8868
Wickr ID: fernandocabral
WhatsApp: +55 (37) 99988-8868
Skype:  fernandojosecabral
Telefone fixo: +55 (37) 3521-2183
Telefone celular: +55 (37) 99988-8868

Enquanto houver no mundo uma só pessoa sem casa ou sem alimentos,
nenhum político ou cientista poderá se gabar de nada.



More information about the User mailing list