.NET Regular expressions on bytes instead of chars

前端 未结 4 1849
栀梦
栀梦 2020-12-29 07:46

I\'m trying to do some parsing that will be easier using regular expressions.

The input is an array (or enumeration) of bytes.

I don\'t want to convert the b

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-29 07:59

    Well, if I faced this problem, I would DO the C++/CLI wrapper, except I'd create specialized code for what I want to achieve. Eventually develop the wrapper with time to do general things, but this just an option.

    The first step is to wrap the Boost::Regex input and output only. Create specialized functions in C++ that do all the stuff you want and use CLI just to pass the input data to the C++ code and then fetch the result back with the CLI. This doesn't look to me like too much work to do.

    Update:

    Let me try to clarify my point. Even though I may be wrong, I believe you wont be able to find any .NET Binary Regex implementation that you could use. That is why - whether you like it or not - you will be forced to choose between CLI wrapper and bytes-to-chars conversion to use .NET's Regex. In my opinion the wrapper is better choice, because it will be working faster. I did not do any benchmarking, this is just an assumption based on:

    1. Using wrapper you just have to cast the pointer type (bytes <-> chars).
    2. Using .NET's Regex you have to convert each byte of the input.

提交回复
热议问题