Re: find/match not working
- Posted by "Kat" <gertie at visionsix.com> Aug 19, 2004
- 481 views
On 18 Aug 2004, at 18:05, Derek Parnell wrote: > > > posted by: Derek Parnell <ddparnell at bigpond.com> > > Kat wrote: > > > found = 0 > > for loop = 1 to length(urllist) do > > if match(junk,urllist[loop]) then > > found = 1 > > exit > > end if > > end for > > if not found then > > urllist = urllist & {junk} > > end if > > When doing this sort of thing, I usually do this ... > > urltemp = upper(urllist) > junk = trim(junk) > found = find(upper(junk), urltemp) > if not found then > urllist = append(urllist, junk) > end if > > In other words, trim both data and do an case-insensitive search. > > The find() function looks for a single element that exactly > matches the subject argument. > > The match() function looks for a set of adjacent elements that > exactly matches all the elements in the subject argument. According to the files i printed out, the items were the same. But find() didn't find them. Kat > To use match() in the way you have above might work better as ... > > if match(junk,urllist[loop]) = 1 and > length(junk) = length(urllist[loop]) then > > in other words, ensure that if you get a match it starts > with the first character and is the same length. But that's > now equivalent to equal()! So it might be better to do ... > > if equal(junk,urllist[loop]) then > > but if you are doing that, you may as well use find() > as it will work faster. > > -- > Derek Parnell > Melbourne, Australia > > > >