whole(string) is in a fld

Dave Cragg dcragg at lacscentre.co.uk
Tue Jun 12 13:52:48 CDT 2007


Hi Hugh

First try.

But like from our clients, we need clearer specs. ;-) What are the  
punctuation rules?

This assumes only final punctuation in the target should be ignored.  
It will try to match punctuation where it exists in the source. It  
will fail if there is double punctuation in the target.



function whole s, t
   put the number of words in s into tNumWords
   put 0 into tCount

   repeat for each word w in t
     put toLower(w) into w2
     put toLower(word tCount + 1 of s) into sW

     // delete punctuation in final word
     if tCount = tNumWords - 1 then
	// but don't remove if source has punctuation also (possible error  
here)
       repeat while last char of w2 is in ".,:;?!" and last char of  
w2 <> last char of sW
         delete last char of w2
       end repeat
     end if
     if sW = w2 then
       add 1 to tCount
       if tCount = tNumWords then
         return true
       end if
     else
       put 0 into tCount
     end if
   end repeat
   return false
end whole


On 12 Jun 2007, at 19:26, FlexibleLearning at aol.com wrote:

> I am trying to write a function that returns whether a given  
> phrase  exists
> in a field as whole words.
>
> e.g.
> put "This is a test." into fld 1 (note the punctuation)
>
> whole("This is a tes",fld 1)  = FALSE
> whole("This is a test",fld 1) = TRUE.
>
> A bit like trying to get the line "This is a tes" is among the  
> words of fld
> 1 to work (obviously it doesn't), even assuming no punctuation  
> were  involved!
>
> I've returned to this little conundrum many times over the years  
> but have
> yet to solve it.
>
> Any offers?
>
> /H
>
>
>
>
>
>
> _______________________________________________
> metacard mailing list
> metacard at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/metacard



More information about the metacard mailing list