bobr wrote:
> sub userInList { my ($user, $userlist) = @_;
> $user =~ s/$userlist//; # a perfect match erases all chars
> return ( $user eq "" ) ? 1 : 0;
> }
The equivalent in REBOL, using REBOL datatypes is:
userInList: func [user [string!] userList [block!]] [
found? find userList user
]
To use PERL data types:
; We need a helper function
RegExp_Block: func [RegExp [string!] /local Exps Exp Exp_Rule][
Exps: make block! 10
Exp: make string! 30
Exp_Rule: [
copy Exp [to "|" | to ")$"]
(append Exps Exp) [thru "|" | thru ")$"]
]
try [parse/all RegExp ["^^(" some Exp_Rule to end] Exps]
]
userInList: func [user [string!] userList [string!]][
found? find RegExp_Block userList user
]
REBOL console:
>> userInList ask "User: " ask "userList: "
User: andrew
userList: ^(bobr|andrew|me" halt "pi
== true
>> userInList ask "User: " ask "userList: "
User: andrew
userList: ^(bobr|andrew|me" halt "pi|me"hum"m^(q)|jeff)$
== true
>> userInList ask "User: " ask "userList: "
User: me"hum"m^(q)
userList: ^(bobr|andrew|me" halt "pi|me"hum"m^(q)|jeff)$
== true
>> userInList ask "User: " ask "userList: "
User: intruder
userList: ^(bobr|andrew|me" halt "pi|me"hum"m^(q)|jeff)$
== false
I'll let someone else do the other part.
I hope that helps!
Andrew Martin
Needing sleep...
ICQ: 26227169
[EMAIL PROTECTED]
http://members.xoom.com/AndrewMartin/
-><-