Task to replace portions of strings within the Input list Output list contains all the elements of the Input list after performing the Regex Replace.
Namespace: MSBuild.Community.Tasks
Assembly: MSBuild.Community.Tasks (in MSBuild.Community.Tasks.dll)
Syntax
Example
1st example replaces first occurance of "foo." with empty string 2nd example replaces occurance of "foo." after character 6 with "oop." string
Copy Code | |
---|---|
<ItemGroup> <TestGroup Include="foo.my.foo.foo.test.o" /> <TestGroup Include="foo.my.faa.foo.test.a" /> <TestGroup Include="foo.my.fbb.foo.test.b" /> <TestGroup Include="foo.my.fcc.foo.test.c" /> <TestGroup Include="foo.my.fdd.foo.test.d" /> <TestGroup Include="foo.my.fee.foo.test.e" /> <TestGroup Include="foo.my.fff.foo.test.f" /> </ItemGroup> <Target Name="Test"> <Message Text="Input:
@(TestGroup, '
')"/> <!-- Replaces first occurance of "foo." with empty string--> <RegexReplace Input="@(TestGroup)" Expression="foo\." Replacement="" Count="1"> <Output ItemName ="ReplaceReturn1" TaskParameter="Output" /> </RegexReplace> <Message Text="
Output Replace 1:
@(ReplaceReturn1, '
')" /> <!-- Replaces occurance of "foo." after character 6 with "oop." string--> <RegexReplace Input="@(TestGroup)" Expression="foo\." Replacement="oop" Startat="6"> <Output ItemName ="ReplaceReturn2" TaskParameter="Output" /> </RegexReplace> <Message Text="
Output Replace 2:
@(ReplaceReturn2, '
')" /> </Target> |
Inheritance Hierarchy
System.Object
Microsoft.Build.Utilities.Task
MSBuild.Community.Tasks.RegexBase
MSBuild.Community.Tasks.RegexReplace
Microsoft.Build.Utilities.Task
MSBuild.Community.Tasks.RegexBase
MSBuild.Community.Tasks.RegexReplace
Thread Safety
Public static (Shared in Visual Basic)staticShared members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.
See Also
Documentation version 1.0.0.0.