Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • I've been trying to utilize Rabin-Karp. The problem is, that all implementations use a static pattern length to speed up their algorithms. I cannot do this, and when I implement it without a constant pattern length, computation times grow exponentially. Commented Jun 25, 2009 at 15:51
  • Oh: The text I am searching is always of length 12286. My patterns are of much shorter length- anywhere from 10 to ~50 characters, and are simply words converted into a hex-string. (ex. BitConverter.ToString(ENCODING.GetBytes("no recoil"))) All that I need is to know if any of my patterns occur in the text. Commented Jun 25, 2009 at 15:56
  • And are there always spaces before and after the words? If so, can you just iterate over the words in the text, and use a normal HashSet<string> to detect whether each word is or isn't a keyword? Commented Jun 25, 2009 at 16:14
  • No. The text is in the form XX-XX-XX-XX-XX where each XX is the hexadecimal representation of a byte from a buffer of memory. In fact, I could solve this problem without dealing with strings at all, but instead search byte arrays for bytes. The only reason that I am converting my data from byte[]'s to strings (which take up more memory and have other performance costs) is because I believed that there were more string searching algorithms than byte searching algorithms... I also hoped that Regex would meet my performance requirements... Commented Jun 25, 2009 at 16:40