I would like to extract the number from a string in MSBuild.
How can I do that using the built in tasks or the MSBuild.Community.Tasks? (RegexMatch might do, but how?)
Example: I have the string
agent0076
and I would like to get out the number, without the leading zeros:
76
<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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With