Boost logo

Boost Users :

From: Keno.Basedow_at_[hidden]
Date: 2004-12-13 10:34:50


Hello,

i try to use the regex library for binary data.
I tried this code:

      string h("\x81\x05\x00\x48");
      regex e2("\x81\x05\x00(.)");
      smatch m;
      if (regex_match(h, m, e2))
      {
            cout << "0. matched=" << (m[0].matched?"true":"false") << endl;
            cout << "0. match length=" << m[0].str().size() << endl;
            cout << "0. match character=" << m[0].str() << endl;
            cout << "1. matched=" << (m[1].matched?"true":"false") << endl;
            cout << "1. match length=" << m[1].str().size() << endl;
            cout << "1. match character=" << m[1].str() << endl;
      }

But regex seems to have problems with the zero character because the result
is:

0. matched=true
0. match length=2
0. match character=ü♣
1. matched=false
1. match length=0
1. match character=

If i change the code above to:

      string h("\x81\x05\x01\x48");
      regex e2("\x81\x05\x01(.)");

and now the result is like intended:

0. matched=true
0. match length=4
0. match character=ü♣☺H
1. matched=true
1. match length=1
1. match character=H

Technical it should be possible to work with zero characters in
basic_string. Is this a bug of regex or is this technical not possible?

Keno Basedow

GEDIS GmbH
Sophienblatt 100
D-24114 Kiel

Fon: +49-431-60051-24 (-0)
Fax: +49-431-60051-11
basedow_at_[hidden]


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net