[dw-free] Overhaul S2
[commit: http://hg.dwscoalition.org/dw-free/rev/a616a20b0980]
http://bugs.dwscoalition.org/show_bug.cgi?id=72
Add some string functions to S2.
Patch by
afuna.
http://bugs.dwscoalition.org/show_bug.cgi?id=72
Add some string functions to S2.
Patch by
--------------------------------------------------------------------------------
diff -r b955bf0164e9 -r a616a20b0980 cgi-bin/LJ/S2.pm
--- a/cgi-bin/LJ/S2.pm Tue Feb 24 08:12:13 2009 +0000
+++ b/cgi-bin/LJ/S2.pm Tue Feb 24 08:15:58 2009 +0000
@@ -4111,6 +4111,22 @@ sub string__contains
return $this =~ /\Q$str\E/;
}
+sub string__replace
+{
+ use utf8;
+ my ($ctx, $this, $find, $replace) = @_;
+ $this =~ s/\Q$find\E/\Q$replace\E/g;
+ return $this;
+}
+
+sub string__split
+{
+ use utf8;
+ my ($ctx, $this, $splitby) = @_;
+ my @result = split /\Q$splitby\E/, $this;
+ return \@result;
+}
+
sub string__repeat
{
use utf8;
--------------------------------------------------------------------------------
