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
Some 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
TIL
Although Rebol can be used for programming, writing functions, and performing processes, its greatest strength is the ability to easily create domain-specific languages or dialects. — Carl Sassenrath [Rebol author]
http://reference.wolfram.com/language/ref/StringExpression.h...
Something like that would be
StringExpression[ "$", Repeated[DigitCharacter], ".", DigitCharacter, DigitCharacter ]
StringExpression[ "$", Repeated[DigitCharacter], ".", Repeated[DigitCharacter, {2}], ]
StringExpression[ "$", NumberString ]
StringExpression[ Repeated[ StringExpression[ Repeated["p", {1, Infinity}], Repeated["q", {2, Infinity}] ], {2} ] ]
Always, not sometimes. ;-)
'$10.00' ~~ rx{ \$ \d+ \. \d\d }; my $pat = rx{ \p+ \q**2..Inf }; 'pqqpqq' ~~ rx{ <$pat>**2 }
TIL
https://en.wikipedia.org/wiki/Rebol