Re: Looking for the best "Parse"...
- Posted by Jiri Babor <jbabor at PARADISE.NET.NZ> Oct 27, 2001
- 399 views
Derek, I hope your day improved after the correction flurry. And since your girls beat our girls at netball again tonight, I had to try a little harder to compensate. I think the simplified function below is just marginally faster than yours. But do not lose any sleep over it... jiri function jparse2(sequence s, sequence s1, sequence s2) -- replace every occurrence of s1 in s by s2 -- case insensitive search sequence os,u,v integer i,j,m os = {} u = lower(s) v = lower(s1) m = length(s1) i = match(v, u) j = 1 while i do os &= s[j..j+i-2] & s2 j += i+m-1 u = u[i+m..length(u)] i = match(v, u) end while return os & s[j..length(s)] end function ----- Original Message ----- From: "Derek Parnell" <ddparnell at bigpond.com> To: "EUforum" <EUforum at topica.com> Sent: Saturday, 27 October 2001 12:34 Subject: Re: Looking for the best "Parse"... > > Okay, I'm having a bad head day. Did anyone else notice the next mistake in > my code? I only handles text which starts with the escape text. Anyhow, to > fix this mistake, replace the lines ... > > -- Initialise the position holders > epos = 0 > spos = 0 > ppos = 0 > > with ... > -- Initialise the position holders > epos = 0 > spos = 1 > ppos = 1 > > ------ > cheers, > Derek.