Regular expressions: Difference between revisions

Content added Content deleted
(Added Oz solution.)
m (→‎{{header|REBOL}}: Fixed spelling errors. How embarrassing.)
Line 541: Line 541:
; Here, I provide a rule to 'parse' that specifies searching through
; Here, I provide a rule to 'parse' that specifies searching through
; the string until "string." is found, then the end of the string. If
; the string until "string." is found, then the end of the string. If
; the subject string satisfies the rule, the expresion will be true.
; the subject string satisfies the rule, the expression will be true.


if parse string [thru "string." end] [
if parse string [thru "string." end] [
print "Subject ends with 'string.'"]
print "Subject ends with 'string.'"]


; For replacment, I take advantage of the ability to call arbitrary
; For replacement, I take advantage of the ability to call arbitrary
; code when a pattern is matched -- everything in the parens will be
; code when a pattern is matched -- everything in the parens will be
; executed when 'to " a "' is satisfied. This marks the current string
; executed when 'to " a "' is satisfied. This marks the current string