mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)
Mark Smith ([staff profile] mark) wrote in [site community profile] changelog2009-02-24 08:16 am

[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 [personal profile] afuna.

--------------------------------------------------------------------------------
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;
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org