[TRE-general] Why Retest fail on these?
OcTweak
octweak at terra.com.br
Wed Feb 21 14:59:06 EET 2007
If \xhh does not work inside [],
how does retest correctly works for the following:
test_comp("[\\x30\\x31]\\x41", REG_EXTENDED, 0);
test_exec("0ABC", 0, REG_OK, 0, 2, END);
test_exec("1ABC", 0, REG_OK, 0, 2, END);
test_exec("2ABC", 0, REG_NOMATCH);
test_comp("[^\\x30\\x31]\\x41", REG_EXTENDED, 0);
test_exec("0ABC", 0, REG_NOMATCH);
test_exec("1ABC", 0, REG_NOMATCH);
test_exec("2ABC", 0, REG_OK, 0, 2, END);
thanks
Anderson
Ville Laurikari wrote:
> On Tue, Feb 20, 2007 at 05:18:49PM -0300, OcTweak wrote:
>
>> Could someone explain me why these tests fail?
>>
>> test_comp("[\\x0D\\x0A]\\x41", REG_EXTENDED, 0);
>> test_exec("\nABC4", 0, REG_OK, 0, 2, END);
>> test_exec("\rABC5", 0, REG_OK, 0, 2, END);
>>
>
> They fail because \xhh (where "hh" is a hex byte) does not work within
> a bracket expression. I'd have to check to be 100% sure, but I think
> POSIX explicitly says that the '\' character loses its special meaning
> within brackets.
>
> This, for example, does work:
> test_comp("(?:\\x0D|\\x0A)\\x41", REG_EXTENDED, 0);
> test_exec("\nABC4", 0, REG_OK, 0, 2, END);
> test_exec("\rABC5", 0, REG_OK, 0, 2, END);
>
> --
> http://www.iki.fi/vl/
>
>
>
More information about the TRE-general
mailing list