Are there any well know REGEX libraries for .NET s

2019-08-05 18:36发布

I understand that .NET's regex works with strings, but I need an implementation for byte[] arrays. Are there any open source implementation in .NET? Does byte[] regex exists for any other programming language other than C# which I can use to build a wrapper for it in C#?

My limitation is that I have to stay within byte arrays. So cannot do any conversions to strings.

Thanks for the advice.

1条回答
Root(大扎)
2楼-- · 2019-08-05 19:18

Regular expressions work with strings. A byte array can contain just about any data. So if you want to use regular expressions convert this byte array into a string using the encoding that was used to encode it. For example if your byte array represents a UTF-8 encoded string:

byte[] buffer = ...
string foo = Encoding.UTF8.GetString(buffer);
// Go ahead and use regexes on foo
查看更多
登录 后发表回答