This question about Using an extension: Answered

SUBST removes anything after match

SUBST macro rewrites string based on regexp matches. However it does not append text after last match

Example:

%SUBST{text="1 2 3 5 4 6 7" pattern="(5) (4)" format="$2 $1"}%

Result: 1 2 3 4 5

Is this expected behaviour? How can I change text in the middle of the string without loosing the end?


Try this patch against FilterPlugin:
--- lib/Foswiki/Plugins/FilterPlugin/Core.pm    (revision 4704)
+++ lib/Foswiki/Plugins/FilterPlugin/Core.pm    (working copy)
@@ -167,7 +167,7 @@
   } elsif ($theMode == 1) {
     # substitution mode
     $result = '';
-    while($text =~ /(.*?)$thePattern/gs) {
+    while($text =~ /(.*?)$thePattern/gcs) {
       my $prefix = $1;
       my $arg1 = $2;
       my $arg2 = $3;
@@ -210,6 +210,9 @@
       $hits--;
       last if $theLimit > 0 && $hits <= 0;
     }
+    if ($text =~ /\G(.*)$/) {
+      $result .= $1;
+    }

-- MichaelDaum - 25 Aug 2009

thanks. now it works ok.

-- AndrejStefanko - 26 Aug 2009

QuestionForm edit

Subject Using an extension
Extension FilterPlugin
Version Foswiki 1.0.5
Status Answered
Topic revision: r3 - 26 Aug 2009, AndrejStefanko - This page was cached on 17 Jan 2018 - 02:55.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License