Find HEX patterns and number of occurrences

心已入冬 提交于 2019-12-04 14:06:05

Sure. Use a sliding window to create the counts (The link is for Perl, but it seems general enough to understand the algorithm). Your patterns are named N-grams. You will have to limit the maximal pattern, though.

This is a pretty classic CS problem. The code in general is non-trivial to implement as it will require at least one full parse of the sequence, and depending on your efficiency and memory/processor constraints might require several. See here.

You will need to partition your input string in some way to ensure that you get a good subsequence across it.

If there is a specific problem we might be able to help more, but the general strategy is in the Wikipedia article above.

You can use Regular Expressions to make a pattern to search for.

The regex needed would be very simple. Just use the exact phrase you're searching for. Then there should be a regular expression function in the language you're using (you didn't specify) that can count the number of matches.

Use that to create a simple counter.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!