4 ms·
Some languages provide alternatives to Regexes. For eg. Rebol uses a parse dialect instead - http://www.rebol.com/docs/core23/rebolcore-15.html http://www.rebo
by draegtun 13y ago
Some languages provide alternatives to Regexes. For eg. Rebol uses a parse dialect instead - http://www.rebol.com/docs/core23/rebolcore-15.html http://www.rebol.com/docs/core23/rebolcore-15.html
Here is the articles example converted to Rebol's parse dialect (minus capturing but it's easy to add):
; build some prereqs for parse
num: charset [#"0" - #"9"]
alpha-lower: charset [#"a" - #"z"]
alpha-upper: charset [#"A" - #"Z"]
alpha: union alpha-lower alpha-upper
alpha-num: union alpha num
; create parse rule block
simple-email-rule: [
alpha
any alpha-num
#"@"
some alpha-num
#"."
some alpha-num
end
]
;
; then later...
parse "valid@example.com" simple-email-rule ; => true
parse "notanemailaddress" simple-email-rule ; => false