On 10 Apr 2005 at 10:27, CBFalconer wrote:
"Prof A Olowofoyeku (The African Chief)" wrote:
I have been trying to implement a "pos" function that only matches whole words. Below is my best effort. Is there a more efficient (or "better") way of implementing this? Thanks.
On looking over this thread I wonder if you are using the best technique for the job, since you don't actually specify the job. [...]
The specific, limited purpose for which I am developing this is for a routine that replaces all occurrences of a substring within a string with another string, viz: "Procedure ReplaceString (const old_str, new_str : string; Var dest : string)" I have a routine like this for a while (using "pos" to find occurrences of "old_str" in "dest"), but I am now trying to extend it to replace optionally only "whole words", hence the need for this "PosInString" function. I think that a hash algorithm is probably too complex for what I am trying to do ... Best regards, The Chief -------- Prof. Abimbola A. Olowofoyeku (The African Chief) web: http://www.greatchief.plus.com/