Regular expressions: Difference between revisions

added sml/nj
(Updated D entry)
(added sml/nj)
Line 1,239:
 
Relatively trivial pattern matching and replacements can be attacked very effectively using regular expressions, but regular expressions (while ubiquitous) are a crippling limitation for more complicated pattern matching problems.
 
=={{header|Standard ML}}==
{{works with|SML/NJ}}
Test
<lang sml>CM.make "$/regexp-lib.cm";
structure RE = RegExpFn (
structure P = AwkSyntax
structure E = BackTrackEngine);
val re = RE.compileString "string$";
val string = "I am a string";
case StringCvt.scanString (RE.find re) string
of NONE => print "match failed\n"
| SOME match =>
let
val {pos, len} = MatchTree.root match
in
print ("matched at position " ^ Int.toString pos ^ "\n")
end;</lang>
 
=={{header|Tcl}}==
Anonymous user