Difference between revisions of "Issue:Includematch with multiple pattern"

From FollowTheScore
Jump to: navigation, search
(Reply)
 
(One intermediate revision by one other user not shown)
Line 4: Line 4:
 
  |Version    = 1.8.9
 
  |Version    = 1.8.9
 
  |Description = Includematch should be able to run multiple patterns on the same include
 
  |Description = Includematch should be able to run multiple patterns on the same include
  |Status      = open
+
  |Status      = close
 
}}
 
}}
  
Line 34: Line 34:
  
 
== Reply ==
 
== Reply ==
 +
Okay, got it myself. Sorry.
 +
 +
<nowiki>
 +
{{#dpl:
 +
|category=Car
 +
|include={Car}:name,{Car¦Template:Invisible},{Car¦Template:Invisible}
 +
|includematch=/color\s*=\s*Red/is,/seats\s*=\s*4/is
 +
}}
 +
</nowiki>
 +
 +
with Template:Invisible containing an "empty" page. --[[User:Tirsales|Tirsales]] 23:43, 3 January 2010 (UTC)
 +
 +
:Right, this way it works. If you can be sure that the pages which call template ''Car'' all use the same sequence of paramaters (i.e. color is always before seats) you could use one regexp which contains the desired values in the proper sequence. Your solution is more general, though - and I doubt that there is a big win in performance if you compress everything into one regexp. --[[User:Gero|Gero]] 21:15, 4 January 2010 (UTC)

Latest revision as of 22:15, 4 January 2010

Description: Includematch should be able to run multiple patterns on the same include
Extension / Version: DPL   /   1.8.9
Type / Status: Change Request   /   close

Problem

I want to search a single include for multiple patterns, all of which have to match. (Example: A single template car having 5 parameters name,color,size,seats,format. Now I want to search for all cars having 4 seats and red color.

AFAIK it should be possible using something akin to

{{#dpl:
|category=Car
|include={Car}:name
|includematch=/color\s*=\s*Red/is,/seats\s*=\s*4/is
}}
 

But this does only filter with the first pattern - if this matches, the second pattern is ignored ..

An alternative would be a way to "invisibly include" a template, so one could use

{{#dpl:
|category=Car
|include={Car}:name,{Car}:color,{Car}:seats
|includematch=/color\s*=\s*Red/is,/seats\s*=\s*4/is
|display=1,-,-
}}
  (or whatever else syntax to include the same template multiple times, but display it only once).


Reply

Okay, got it myself. Sorry.

{{#dpl:
|category=Car
|include={Car}:name,{Car¦Template:Invisible},{Car¦Template:Invisible}
|includematch=/color\s*=\s*Red/is,/seats\s*=\s*4/is
}}
 

with Template:Invisible containing an "empty" page. --Tirsales 23:43, 3 January 2010 (UTC)

Right, this way it works. If you can be sure that the pages which call template Car all use the same sequence of paramaters (i.e. color is always before seats) you could use one regexp which contains the desired values in the proper sequence. Your solution is more general, though - and I doubt that there is a big win in performance if you compress everything into one regexp. --Gero 21:15, 4 January 2010 (UTC)