After digging down the code, there is a solution to your problem. You have
to use the octal representation for the replacing character. The following
code will replace single quotes for double quotes:
string Texto2 = regsub(Texto, "[']", "\0042")
print Texto2
---
Leaving the regsub code as is, maybe the documentation should be improved.
Get it from
https://developer.gnome.org/glib/stable/glib-Perl-compatible-regular-expr...
If Allin or Jack want me to have a try to improve the regex processing I
could have a go.
Hélio
On Mon, May 18, 2015 at 11:18 PM, Hélio Guilherme <helioxentric(a)gmail.com>
wrote:
Hi Henrique,
I think you found a bug. The following code works fine:
string Texto2 = regsub(Texto, "[']", "\\")
print Texto2
But only works for the "\\", of you try with other escaped chars it fail.
As an example of Perl regex, the following Unix command gives the expected
result.
sed "s/[']/\"/g" "Morte e Vida SeverinaSeverino.txt"
Hélio
On Mon, May 18, 2015 at 8:43 PM, Henrique Andrade <
henrique.coelho(a)gmail.com> wrote:
> Em 18 de maio de 2015, Sven escreveu:
>
> Am 18.05.2015 um 21:17 schrieb Henrique Andrade:
>>
>>> Dear Gretl Community,
>>>
>>> How can I use quotation marks inside a Gretl function that deals with
>>> strings? (...)
>>>
>>
>> I'm not 100% sure what your question is, but the help for strsub() says
>> to use the regsub() function for more complex stuff, so that would probably
>> be my advice.
>>
>
> Dear Sven, thanks for your attention!
>
> I tested with the resub and I got no success. Take a look at the
> following code:
>
> string Texto = sprintf("\n\
> O meu nome é 'Severino',\n\
> como não tenho outro de pia.\n\
> Como há muitos 'Severinos',\n\
> que é santo de romaria,\n\
> deram então de me chamar\n\
> 'Severino de Maria'.")
>
> string Texto1 = strsub(Texto, "'", "*")
> print Texto1
>
> string Texto2 = regsub(Texto, "'", "\"")
> print Texto2
>
> We can generate Texto1, but Texto2 fails.
>
> Best,
> Henrique
>
>
> _______________________________________________
> Gretl-users mailing list
> Gretl-users(a)lists.wfu.edu
>
http://lists.wfu.edu/mailman/listinfo/gretl-users
>