C#中的8位模式搜索 [英] 8-bit pattern search in c#`

查看:67
本文介绍了C#中的8位模式搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要c#中的代码,用于从数据中搜索特定的模式,例如01111110.
任何帮助将不胜感激.

问候

I need a code in c#, for searching a specific pattern, say 01111110, from the data.
Any help will be appreciated.

Regards

推荐答案

据我了解,您不是在寻找与您的模式匹配的特定字节(搜索字节[]数组很简单),而是您的是否需要在数据中的任何地方匹配模式,也许跨越字节边界?如果是这样,我只能为您扫描数据的每个字节中模式开始的位,然后将下一个位(如果必须越过字节边界,则取自下一个字节)与模式的第二位进行比较,因此上.绝对可以改进此算法(非常简单).检查用于子字符串搜索的算法,可以在此处应用
As far as I understand, you are not looking for a specific byte matching your pattern (that would be trivial, searching byte[] array), but your need to match pattern anywhere in the data, maybe crossing byte boundaries? If so, I can only offer you to scan each byte of data for the bit your pattern starts with, then compare next bit (maybe taken from the next byte, if you must cross byte boundaries) with the second bit of a pattern and so on. Definitely this - very straightforward - algorithm may be improved. Check algorithms for substring search, they may be applied here


检查以下对它们可能有帮助的文章:

http://stackoverflow.com/questions/283456/byte-array-pattern-search [ ^ ]

http://www.lulu.com/items/volume_63/1995000/1995848/9/print/all.pdf [ ^ ]
Check the following articles they might help you:

http://stackoverflow.com/questions/283456/byte-array-pattern-search[^]

http://www.lulu.com/items/volume_63/1995000/1995848/9/print/all.pdf[^]


您可以将8位模式转换为字节,然后可以转换下一个
将8位转换为一个字节并进行比较...
you can convert the 8-bit pattern into a byte, then you can transform the next
8-bits into a byte and compare it...


这篇关于C#中的8位模式搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆