正则表达式 – 从MSBuild中的字符串中提取数字
发布时间:2020-12-14 06:27:34 所属栏目:百科 来源:网络整理
导读:我想从MSBuild中的字符串中提取数字. 如何使用内置任务或MSBuild.Community.Tasks? (RegexMatch可能会做,但是怎么样?) 示例:我有字符串 agent0076 我想排除数字,没有前导零: 76 使用MSBuild 4属性函数 Target Name="Regex" PropertyGroup Inagent0076/In
我想从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> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |