[Gambas-user] RegExp.Replace() question

Fernando Cabral fernandojosecabral at ...626...
Sat Apr 29 23:40:33 CEST 2017


Benoît

I am prety new to Gambas, but quite an old hand with regular expression
(almost from the time when sed, awk and vi were created. All of them allow
heavy use of regular expression). It took me many hours to understand that,
contrary to customs,
Gambas regex are ungreedy. It took me some more hours to find out that "?"
could be used to make the operators
+ and * to work as usual (I mean, for old hands like me). And half an hour
more to find out that "&1" replace the older "\1" and not so old "$1".
Those things are annoying when you are getting used to a new lingo.

Even so, I am very impressed with the power you have built into Gambas.
Amazing.

-fernando

2017-04-29 11:04 GMT-03:00 Benoît Minisini <gambas at ...1...>:

> Le 29/04/2017 à 13:48, Tobias Boege a écrit :
> >
> > Yes, admittedly it is strange behaviour of RegExp.Replace() to invert
> > the greediness of all quantifiers and it was discovered just a few days
> > ago. I don't know if it is going to be fixed though. I bet there was a
> > rationale behind this setting, but we'll have to wait for a comment of
> > Benoit who wrote the code.
> >
>
> I have no idea about why I forced the PCRE_UNGREEDY flag. :-/
>
> Maybe to match the behaviour of the Gambas Replace() function.
>
> The only thing I can do is the following: when specifying explicitly the
> RegExp.Ungreedy constant in the RegExp.Replace() options, then do the
> contrary (remove the ungreedy flag).
>
> What do you think about that?
>
> --
> Benoît Minisini
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



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