This appears to work:
CharsAccepted: func [acceptable[string!] submitted[string!] /local
inter-set exc-set]
[
  inter-set: intersect acceptable submitted
  if (length? inter-set) <> (length? submitted)
    [make error! rejoin[exclude submitted inter-set " are not acceptable
characters"]]
  return true
]
Thanks Allen! :>)
Tim
At 12:14 PM 6/2/00 +1000, you wrote:
>
>----- Original Message -----
>From: <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Friday, June 02, 2000 11:27 AM
>Subject: [REBOL] Screening chars from strings
>
>
>> Hi:
>> I want to write a function that tests a string
>> for an exclusive set of characters:
>> ex:
>> found-unwanted: func [str[string!] allowed[string!]]
>> [
>> ;test <str> to make sure that only characters in
>> ; <allowed> are present, return true if not all
>> ; characters in <str> match characters in <allowed>
>> ]
>>
>> found-unwanted "abd" "abc"
>> == true
>> ; the first parameters contains a 'd' which is not allowable,
>> ;  because it is not found in the second parameter
>> Given what I know now, I can do this in about 5 lines of rebol code.
>> I bet someone out there can do it in 1!!
>> Thanks folks!
>> Tim
>>
>
>Hi Tim,
>
>Rather than give you a direct answer I'll just point you at a few built in
>functions which are good for dealing with sets. (note some of them are in
>view but will be in the next core release). Many of these can provide a one
>line solution for your problem, (by testing the length of the resultant
>string).
>
>difference
>union
>unique
>exclude
>
>And one that isn't always so obvious (beware though trim is case sensitive,
>at least in the latest view version)
>
>trim/with
>
>Cheers,
>
>Allen K
>
>
>
>

Reply via email to