This filter replaces all occurrences of a given string in the original
input stream with a user-supplied replacement string. By default string
comparisons are case sensitive but this can be changed by setting the
optional NAnt.Core.Filters.ReplaceString.IgnoreCase
attribute to true
.
To use this filter specify the string to be replaced with the
NAnt.Core.Filters.ReplaceString.From
attribute and the string to replace it with using the
NAnt.Core.Filters.ReplaceString.To
attribute.
Filters are intended to be used as a element of a NAnt.Core.Filters.FilterChain
.
Parameters
Attribute | Type | Description | Required |
---|---|---|---|
from | string |
The string to be replaced.
|
True |
ignorecase | bool |
Determines if case will be ignored.
The default is
false .
|
False |
to | string |
The new value for the replaced string.
Am empty string is permissible.
|
False |
if | bool |
If
true then the filter will be used; otherwise,
skipped. The default is true .
|
False |
unless | bool |
Opposite of
NAnt.Core.Filters.Filter.IfDefined . If false
then the filter will be executed; otherwise, skipped. The default
is false .
|
False |
Examples
Replace all occurrences of "3.14" with "PI".
<replacestring from="3.14" to="PI" />
Replace all occurrences of "string", "String", etc. with "System.String".
<replacestring from="String" to="System.String" ignorecase="true" />
Requirements
- Assembly
- NAnt
.Core .dll - Namespace
-
NAnt
.Core .Filters