by jrullmann on 2/11/15, 2:59 PM with 54 comments
by draegtun on 2/11/15, 6:21 PM
digits: digit: charset "0123456789"
rule: [
thru "$"
some digits
"."
digit
digit
]
parse "$10.00" rule ;; true
pattern: [
some "p"
2 "q" any "q"
]
new-rule: [
2 pattern
]
parse "pqqpqq" new-rule ;; true
Rebol doesn't have regular expressions instead it comes with a parse dialect which is a TDPL - http://en.wikipedia.org/wiki/Top-down_parsing_languageSome parse refs: http://en.wikibooks.org/wiki/REBOL_Programming/Language_Feat... | http://www.rebol.net/wiki/Parse_Project | http://www.rebol.com/r3/docs/concepts/parsing-summary.html
by tragomaskhalos on 2/11/15, 4:21 PM
by marktangotango on 2/11/15, 4:52 PM
by UnoriginalGuy on 2/11/15, 5:02 PM
I've "learned" regular expressions multiple times but it just never sticks, I have no idea why. It certainly doesn't help that there are several different incompatible syntaxes (so what I remember and think "should" work doesn't).
I'd prefer to write RegX's in this style, however I would pay attention to performance (not that Regular Expressions are high performance, however I wouldn't want to see a large performance loss either).
by chris-at on 2/11/15, 3:12 PM
``` (?xi) \b ( # Capture 1: entire matched URL (?: [a-z][\w-]+: # URL protocol and colon (?: /{1,3} # 1-3 slashes | # or [a-z0-9%] # Single letter or digit or '%' # (Trying not to match e.g. "URI::Escape") ) | # or www\d{0,3}[.] # "www.", "www1.", "www2." … "www999." | # or [a-z0-9.\-]+[.][a-z]{2,4}/ # looks like domain name followed by a slash ) (?: # One or more: [^\s()<>]+ # Run of non-space, non-()<> | # or \(([^\s()<>]+|(\([^\s()<>]+\)))\) # balanced parens, up to 2 levels )+ (?: # End with: \(([^\s()<>]+|(\([^\s()<>]+\)))\) # balanced parens, up to 2 levels | # or [^\s`!()\[\]{};:'".,<>?«»“”‘’] # not a space or one of these punct chars ) ) ```
by jluxenberg on 2/11/15, 6:02 PM
e.g.
(: (or (in ("az")) (in ("AZ")))
(* (uncase (in ("az09")))))
by jgalt212 on 2/11/15, 5:18 PM
These web based tools can do it:
by dkarapetyan on 2/11/15, 4:56 PM
by zzzcpan on 2/11/15, 10:55 PM
I get that some people have a hard time understanding regexpes with all the backtracking and greediness. Yes, syntax is a bit complicated. Maybe simplified predictable default mode could help. But there is no problem with DSL being used as an abstraction. In fact, we need more DSLs, for everything!
by psychometry on 2/11/15, 5:19 PM
by kazinator on 2/11/15, 6:20 PM
(compound "$" (1+ :digit) "." :digit :digit)
Run: $ txr -p "(regex-compile '(compound \"$\" (1+ :digit) \".\" :digit :digit))"
#/$\d+\.\d\d/
by epicureanideal on 2/11/15, 7:45 PM
by otakucode on 2/11/15, 10:56 PM
by gcao on 2/11/15, 4:17 PM