Hi, Andrew

I think this is a job for parse.

rebol[]

findany: func [x [string!] y [block!] /local rule][
 foreach word y [
  ; build a block like [to "dog" to end]
  rule: append append copy [to] word [to end]
  ;print [mold rule]
  if parse x rule [return true]
 ]; foreach
 return false 
]

x: "There is a dog in the barn"
y: ["pig" "dog" "skunk"]

xx: "Parse is an wonderful yet not so simple function"
yy: ["rebol" "complex" "program"]
yyy: ["rebol" "function"]

findany x y
findany xx yy
findany xx yyy

Patrick


----- Original Message ----- 
From: "Andrew Martin" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, December 12, 2001 7:55 PM
Subject: [REBOL] Re: Search string x for any substring found in block y.


> Louis wrote:
> >           findany: func [
> 
> Try:        find-any: func [
> 
> >           if find x y/count [true break]
> 
> Try:        if found? find x y/:count [return true]
> 
> > if findany x y [print found]
> 
> Try:        if find-any x y [print "found"]
> 
> And this is a better replacement for 'findany:
> 
>         find-any: func [x [string!] Strings[block!]][
>             foreach String Strings [
>                 if found? find x String [return true]
>                 ]
>             ]
> 
> I hope that helps somewhat!
> 
> Andrew Martin
> ICQ: 26227169 http://valley.150m.com/
> -><-
> 
> 
> 
> -- 
> To unsubscribe from this list, please send an email to
> [EMAIL PROTECTED] with "unsubscribe" in the 
> subject, without the quotes.
> 

 
______________________________________________________________________________
ifrance.com, l'email gratuit le plus complet de l'Internet !
vos emails depuis un navigateur, en POP3, sur Minitel, sur le WAP...
http://www.ifrance.com/_reloc/email.emailif


-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to