March 2014 update

This commit is contained in:
Ingy döt Net 2014-04-02 16:56:35 +00:00
parent 09687c4926
commit a25938f123
1846 changed files with 21876 additions and 5203 deletions

View file

@ -1,12 +1,12 @@
import std.stdio, std.regex;
void main() {
immutable string s = "I am a string";
import std.stdio, std.regex;
// Test:
if (!match(s, r"string$").empty)
writeln("Ends with 'string'.");
immutable s = "I am a string";
// Substitute:
replace(s, regex(" a "), " another ").writeln();
// Test.
if (!s.match(r"string$").empty)
"Ends with 'string'.".writeln;
// Substitute.
s.replace(" a ".regex, " another ").writeln;
}

View file

@ -0,0 +1,10 @@
RegExp regexp = new RegExp(r'\w+\!');
String capitalize(Match m) => '${m[0].substring(0, m[0].length-1).toUpperCase()}';
void main(){
String hello = 'hello hello! world world!';
String hellomodified = hello.replaceAllMapped(regexp, capitalize);
print(hello);
print(hellomodified);
}

View file

@ -0,0 +1,2 @@
$ txr -p '(regex-parse "a.*b")'
(compound #\a (0+ wild) #\b)

View file

@ -0,0 +1,2 @@
$ txr -p "(regex-compile '(compound #\a (0+ wild) #\b))"
#<sys:regex: 9c746d0>

View file

@ -0,0 +1,2 @@
$ txr -p '(regsub #/a+/ "-" "baaaaaad")'
"b-d"