On Sat, 29 Apr 2017, Fernando Cabral wrote: > 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. >
But these two things could have been cleared up by looking at the right portion(!) of the documentation, which is often hard to find in the beginning, I know. RegExp.Replace() is a method of the RegExp class which resides in the gb.pcre component. Its main page in the wiki [1] tells you that PCRE are Perl-Compatible Regular Expressions and links to the libpcre [2] page for its syntax. The Replace() method page [3] itself tells you to use "&1" for backreferences. This is for consistency with the Subst$() intrinsic function and other substitution functions in Gambas which came before RegExp.Replace() -- all of them use "&1". And for the future: you will encounter another type of regular expressions much more often in Gambas than the PCREs, namely the LIKE expressions [4]. You will notice that they are very primitive, maybe too primitive if you're used to sed-style expressions, and have an incompatible syntax. Regards, Tobi [1] http://gambaswiki.org/wiki/comp/gb.pcre [2] http://gambaswiki.org/wiki/doc/pcre [3] http://gambaswiki.org/wiki/comp/gb.pcre/regexp/replace [4] http://gambaswiki.org/wiki/lang/like -- "There's an old saying: Don't change anything... ever!" -- Mr. Monk ------------------------------------------------------------------------------ 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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user