我想从MSBuild中的字符串中提取数字.
如何使用内置任务或MSBuild.Community.Tasks? (RegexMatch可能会做,但是怎么样?)
示例:我有字符串
agent0076
我想排除数字,没有前导零:
76
使用MSBuild 4属性函数
<Target Name="Regex">
<PropertyGroup>
<In>agent0076</In>
<Out>$([System.Text.RegularExpressions.Regex]::Match($(In),`[1-9]\d*`))</Out>
</PropertyGroup>
<Message Text="Input : $(In) Output : $(Out)"/>
<!-- Input : agent0076 Output : 76 -->
</Target>