Whilst writing a string replace function for Mathcad Express, I found what seems to be a problem with the string function search. I wanted to check a string for the existence of the Unicode characters for 11 (↊) and 12 (↋) in the duodecimal system ... and it found them everywhere even when they weren't there at all.
Has this been noticed before? Have I made some kind of error or unwitting assumption?
(The simple recursive algorithm shown above is O(n) and only good for strings shorter than about 4000 characters (ie, under Mathcad's recursion depth limit. A slightly more complicated algorithm would use a binary-division algorithm to reduce the recursion stack to O(log n), which will handle much longer strings)
Interesting bug, indeed
Here Mathcad 15 (even a bit worse 😉
The search is worse than you may think. Out of the first 8000 Unicode characters, search incorrectly found 1238 characters. Quite some going.
(the first 4 characters in the table below are genuine finds; I put them in to give confidence that my method was using search as intended)
Here's the result of using the built-in search on the first 4000 characters vs a replacement search: