Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,4 @@
var str = "I am a string";
if (str =~ /string$/) {
print "Ends with 'string'\n";
}

View file

@ -0,0 +1,8 @@
var str = <<'EOF';
x:Foo
y:Bar
EOF
while (var m = str=~/(\w+):(\S+)/g) {
say "#{m[0]} -> #{m[1]}";
}

View file

@ -0,0 +1,12 @@
var str = "I am a string";
# Substitute something mached by a regex
str.sub!(/ a /, ' another '); # "I am a string" => "I am another string"
# Remove something matched by a regex
str -= / \Kanother /i; # "I am another string" => "I am string"
# Global subtitution with a block
str = str.gsub(/(\w+)/, {|s1| 'x' * s1.len}); # globaly replace any word with 'xxx'
say str; # prints: 'x xx xxxxxx'