Difference between revisions of "DPL:Manual - dplreplace"

From FollowTheScore
Jump to: navigation, search
(New page: {{Type Manual|section=dplreplace}} === Syntax === <pre><nowiki> {{#dplreplace:|pattern|replacement|text}} </nowiki></pre> === Effect === Replaces the given ''pattern'' within the ''...)
 
Line 4: Line 4:
  
 
<pre><nowiki>
 
<pre><nowiki>
   {{#dplreplace:|pattern|replacement|text}}
+
   {{#dplreplace:text|pattern|replacement}}
 
</nowiki></pre>
 
</nowiki></pre>
  
Line 12: Line 12:
  
 
''pattern'' is a regular expression as defined by php <tt>preg_replace()</tt>.
 
''pattern'' is a regular expression as defined by php <tt>preg_replace()</tt>.
 +
 +
''replacement'' may contain references to matching parts.
  
 
=== Example ===
 
=== Example ===
  
<pre><nowiki>
+
<nowiki> {{#dplreplace:abrakadabra|ab|AB}} </nowiki>   returns:  {{#dplreplace:abrakadabra|ab|AB}}
{{#dplreplace:ab|AB|abrakadabra}}
+
 
</nowiki></pre>
+
<nowiki> {{#dplreplace:abrakadabra|a(.)|A\1}} </nowiki> returns:   {{#dplreplace:abrakadabra|a(.*?r)|A\1}}
{{#dplvar:set|a|x|b|y|c|z}} {{#dplvar:default|a|aaaa}} {{#dplvar:default|d|dddd}}
 
{{#dplreplace:ab|AB|abrakadabra}}
 
  
 
[[Category:DPL Manual]]
 
[[Category:DPL Manual]]

Revision as of 07:35, 13 October 2009

Manual dplreplace

Syntax

  {{#dplreplace:text|pattern|replacement}}

Effect

Replaces the given pattern within the text by replacement.

pattern is a regular expression as defined by php preg_replace().

replacement may contain references to matching parts.

Example

 {{#dplreplace:abrakadabra|ab|AB}}     returns:   ABrakadABra
 {{#dplreplace:abrakadabra|a(.)|A\1}}  returns:   AbrAkadabra