Issue:Includematch parameter regexp issue

From FollowTheScore
Revision as of 15:05, 12 October 2007 by Gri6507 (talk | contribs) (New page: {{Issue |Type = Bug |Extension = DPL |Version = 1.4.7 |Description = includematch parameter does not work with complex regexp |Status = open }} == Problem == I have...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Description: includematch parameter does not work with complex regexp
Extension / Version: DPL   /   1.4.7
Type / Status: Bug   /   open

Problem

I have the following templates: Template:Todo with the following code

Do task for project {{{project}}}

where the project= option is a comma separated list of projects to which this particular TODO is associated with (see below for valid variations of project option). I also have the following template Template:Todo.dpl with the following code

<includeonly>
* {{{1}}}
</includeonly>


I want to write a DPL query to display only the tasks assigned to a particular project (let's call it myproj). I tried doing the following

<dpl>
  uses=Template:Todo
  include={Todo}.dpl
  includematch=/project\s*=\s*([^,]*,)*\s*myproj\s*(,[^,]*\s*)*$/i
</dpl>

However, when I view a page with this DPL code, I get a LOT of error messages similar to Warning: preg_match() [function.preg-match]: No ending delimiter '/' found in /export/www/html/npdwiki/extensions/DynamicPageList/DynamicPageList2Include.php on line 429 and the results are not correct: the query does not display any matches.

The following PHP code demonstrates the application of this template to match against several valid and invalid options for project= parameter.

<?php

$test = array();
array_push($test, "project=myproj");
array_push($test, "project = myproj");
array_push($test, "project = blah,  myproj");
array_push($test, "project=blah ,   myproj");
array_push($test, "project = blah blah blah , myproj ");
array_push($test, "project = myproj, blah blah");
array_push($test, "project = blah , myproj , blah");
array_push($test, "project = myproj two");
array_push($test, "project = blah, myproj two, blha");
array_push($test, "project = myproj ,myproj two");
array_push($test, "project = myproj two , myproj");

foreach ($test as $t) {
    print "testing '$t' ==> ";
    if (preg_match('/project\s*=\s*([^,]*,)*\s*myproj\s*(,[^,]*\s*)*$/i', $t))
        print "match \n";
    else
        print "NOT matching\n";
}

?>
--Gri6507 16:05, 12 October 2007 (CEST)


Reply