Author Topic: string replace algo???  (Read 222 times)

daydreamer

  • Member
  • ***
  • Posts: 492
string replace algo???
« 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
« Last Edit: June 11, 2018, 05:58:36 AM by daydreamer »
Quote from Flashdance
Nick  :  When you give up your dream, you die.
*wears a flameproof asbestos suit*

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 5634
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: string replace algo???
« Reply #1 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

daydreamer

  • Member
  • ***
  • Posts: 492
Re: string replace algo???
« Reply #2 on: May 28, 2018, 05:08:00 AM »
thanks Hutch
I start with simple replace algo
Quote from Flashdance
Nick  :  When you give up your dream, you die.
*wears a flameproof asbestos suit*