The MASM Forum

General => The Campus => Topic started by: daydreamer on May 28, 2018, 03:47:03 AM

Title: string replace algo???
Post by: daydreamer on May 28, 2018, 03:47:03 AM
Hi
I feel I am stuck with option of brute force solution,I want to learn of string algos to see if I can find a faster,better algo
wouldnt the fastest be a search tree algo?
I have not enough experience in string algos
I have worked on few .inc files and one testdata file and reduced .inc files from 800bytes to around 180bytes
also needed is support a unicode version of "-",that is inserted in Words, to show long pronouncation of vokal
Title: Re: string replace algo???
Post by: hutch-- on May 28, 2018, 03:59:51 AM
A normal string replace scans for the start character then branches to test if its a match or not, if it matches, the string replacement is written to the start character location to overwrite the string that has been found then continues with the first character scan. What complicate a replace algo is if the replacement is longer than the string it replaces, to solve this you first scan the string to see how many instances of the word to replace exist, do the arithmetic and allocate a big enough buffer to hold the result.
Title: Re: string replace algo???
Post by: daydreamer on May 28, 2018, 05:08:00 AM
thanks Hutch
I start with simple replace algo