March 2014 update
This commit is contained in:
parent
09687c4926
commit
a25938f123
1846 changed files with 21876 additions and 5203 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
10
Task/Regular-expressions/Dart/regular-expressions.dart
Normal file
10
Task/Regular-expressions/Dart/regular-expressions.dart
Normal 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);
|
||||
}
|
||||
2
Task/Regular-expressions/TXR/regular-expressions-3.txr
Normal file
2
Task/Regular-expressions/TXR/regular-expressions-3.txr
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
$ txr -p '(regex-parse "a.*b")'
|
||||
(compound #\a (0+ wild) #\b)
|
||||
2
Task/Regular-expressions/TXR/regular-expressions-4.txr
Normal file
2
Task/Regular-expressions/TXR/regular-expressions-4.txr
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
$ txr -p "(regex-compile '(compound #\a (0+ wild) #\b))"
|
||||
#<sys:regex: 9c746d0>
|
||||
2
Task/Regular-expressions/TXR/regular-expressions-5.txr
Normal file
2
Task/Regular-expressions/TXR/regular-expressions-5.txr
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
$ txr -p '(regsub #/a+/ "-" "baaaaaad")'
|
||||
"b-d"
|
||||
Loading…
Add table
Add a link
Reference in a new issue