[Gambas-user] Reg expression still beating me up

Fernando Cabral fernandojosecabral at ...626...
Mon May 29 00:17:17 CEST 2017


In the piece of code bellow, RegExp.Replace will never return.

Sentencas[i] = "Test string."
Print "Before replacing"
Sentencas[i] = RegExp.Replace(Sentencas[i], "[.:!?;]*[ ]*?\n*?", "",
RegExp.UTF8)
Print "After replacing"

It beats me, because what it should do is very simple: optionally find one
of the punction marks (.:?!;) optionally followed by any number of white
space, optionally followed by any number of "\n" (end of line). Replace
whatever is found with an empty string.

In the text string, it should find the dot (.) and replace it with nothing.
So, the returned string should be "Test string".

Alas! It will never come back. Same if I replace the test string with
"Test string. \n" or "Test string.\n"

Now, this works as expected, but this is not what I need:  "[.:!?;][
]*?\n*?", ""
To my eyes, "[.:!?;]*[ ]*?\n*?" is a perfectly valid regular expression.

Any hints?


-- 
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