Dave Cragg
Mon, 02 Jul 2007 03:48:58 -0700
Hi HughUsual technique to seek extra time from a client is to ask more questions. :-)
I assume the string has to match on the start of a word boundary.
e.g.
put "This is a test." into sourceText (note the punctuation)
whole("is is a test",sourceText) => FALSE
Case-sensitivity?
Dave
On 13 Jun 2007, at 20:35, [EMAIL PROTECTED] wrote:
The Challenge:"Write a function that returns TRUE or FALSE for the existence of any valid text string existing within any longer text string. (To make things easier we limit this to ASCII text; right-to-left double-bite Unicode character recognition can come later :-)" e.g. put "This is a test-piece." into sourceText (note the punctuation) whole("This is a test",sourceText) => FALSE whole("This is a test-piece",sourceText) => TRUE1. Philip's "creative thinking" entry (that unfortunately only handlestail-end period punctuation):put "This is a test." into myLine replace " " with "*" in myLine put fld 1 into myFieldreplace ". " with ".#" in myField (note : period + space. use two spacesif needed)replace space with "*" in myField replace "#" with space in myField if myLine is among the words of myField then return true2. Dave's "almost there" entry....This doesn't check that the matched target starts on a word boundary,But a simple check on char (tOff -1) or whether tOff is at the beginning of the target shoud do it. function whole s,t put length(s) into tNumChars put ",.;:?!" & space & tab & cr & numToChar(13) into tWB put offset(s,t) into tOff if tOff = 0 then return falsereturn length(t) = (tOff + tNumChars - 1) OR char (tOff + tNumChars) oft is in tWBend whole3. Ken's "sneaky" entry that relies on a field as the source (probably because I did not spec out the problem properly, meant stringSource rather thanfield, and he's too damn good at reading things carefully):put wholeWordMatch("This is a test",long id of fld 1) function wholeWordMatch pFindText,pFldRef find whole pFindText in pFldRef put the result into tResult find empty return (tResult <> "not found") end wholeWordMatchAnyone care to top these? The winner will be placed in the stdLib assumingcommon consent! /H _______________________________________________ metacard mailing list metacard@lists.runrev.com http://lists.runrev.com/mailman/listinfo/metacard
_______________________________________________ metacard mailing list metacard@lists.runrev.com http://lists.runrev.com/mailman/listinfo/metacard