Here's what I've got so far:
RegExp_Parse: function [RegExp [string!]] [
RegExp_Rules RegExp_Parser Match Match_Character Match_Characters
][
RegExp_Parser: make block! 4 * length? RegExp
Match: make string! 0
Match_Character: charset [#"0" - #"9" #"A" - #"Z" #"a" - #"z"]
Match_Characters: [some Match_Character]
append RegExp_Parser [to]
RegExp_Rules: [
"^^" (if 'to = first RegExp_Parser [remove head RegExp_Parser]) |
"*" (append RegExp_Parser [| none]) |
"?!" (append RegExp_Parser [noty]) |
"|" (append RegExp_Parser [|]) |
"$" (append RegExp_Parser [end]) |
"(" |
")" |
copy Match Match_Characters (append RegExp_Parser Match)
]
parse/all RegExp [some RegExp_Rules]
RegExp_Parser
]
RegExp: func [RegExp [string!] Exp [string!]] [
parse/all probe Exp probe RegExp_Parse RegExp
]
print RegExp "^^(ted|admin|bobr|andrew|elan|keith|cheryl|joel|brady)$"
"intruder"
print RegExp "^^(ted|admin|bobr|andrew|elan|keith|cheryl|joel|brady)$"
"cheryl"
And here it is running:
>> do %bobr.r
Script: "bobr" (20-Jan-1999)
"intruder"
["ted" | "admin" | "bobr" | "andrew" | "elan" | "keith" | "cheryl" | "joel"
| "brady" end]
false
"cheryl"
["ted" | "admin" | "bobr" | "andrew" | "elan" | "keith" | "cheryl" | "joel"
| "brady" end]
true
Parenthesis don't work, yet. Gabrielle, Elan? Feel free to improve it.
I've also noticed that _two_ calls to parse in the one function doesn't seem
to work right.
Andrew Martin
ICQ: 26227169
[EMAIL PROTECTED]
http://members.xoom.com/AndrewMartin/
-><-