Absolutely. There are actually a few functions that will do this, with varying degrees of precision and with varying options. Check out String Functions in the help file (or, even better, in Brian's book) for a list of the options.
One of the handy things about Crystal is that it treats a string as an array of characters. So, in addition to the built-in string functions, you can also use any array functions on it. This can allow you to perform some really wacky operations, should you really need it (like parsing out address information from untrained user input).
|
Oh ho! Now that's a tricky little problem.
OK, first of all, if you enter "1234," do you want 2uy4gty3u1 returned? I.e., does order matter? What about 1112233344?
If order does matter, and duplicates don't, then you can still use "LIKE." You just need to put an asterisk between each character, e.g. LIKE "*1*2*3*4*".
If order doesn't matter, this gets trickier. Let me know if that's the case. Normally, I would check that by simply looping through the string. But, I'm not sure you can put a loop structure in your selection criteria. Of course, if the entry is always the same length, or at least has a guaranteed maximum length, then you can do it brute force style, without a loop. Well, in this case, I guess 25 is certainly the maximum, but that's going to be a nasty long brute force query.
If duplicates do matter, then it gets really tricky. Especially if you allow duplicates in the search string, and the result has to have the same number of duplicates. E.g., if you enter 1122, it will return 1*1*2*2, but not 1*1*1*2*2 or 1*2*2. The easiest way I could see to do that would be with nested loops. But, again, I'm not sure that's allowed.
|