Here's a riddle for PHP coders out there...
I want to take a string, and find patterns. RegExp, you say?
Exactly, but it gets a little more complex than that.
You see, I don't know what I am looking for.
Neither will the code.
The only thing we know is that we want to find the largest "patterns" in a file, and replace it with a number.
Here's an example of what I am talking about, "pseudocode" style:
Text to be scanned:
God is great, God is good,
Let us thank him for our food.
Scan complete. Largest pattern: "God is g"
Found twice, replaced with "1", noted and removed.
Now we have:
1reat, 1ood,
Let us thank him for our food.
Second scan complete. Largest pattern: "ood"
Found twice, replaced with "2", noted and removed.
Now we have:
1reat, 12,
Let us thank him for our f2.
Third scan complete. Largest pattern: "r_" (Underscore is whitespace)
Found twice, noted and removed.
Now we have:
1reat, 12,
Let us thank him fo3ou3f.
No more patterns of two or greater. Therefore, pattern matching is over.
Now, imagine this on a work like Hamlet. I think you see what I am saying.
Thanks in advance!