用于在版本

时间:2018-11-05 23:02:29

标签: regex teamcity

我正在使用“文件内容替换器”在版本字符串中将“内部版本号”替换为“ build.counter”(13468)。

File content replacer

这是文件“ AssemblyInfoVersion.cs”中的内容。

using System.Reflection;

[assembly: AssemblyVersionAttribute("3.0.1923.999")]

这是“文件内容替换器”的消息

File content replacer] Applying replacement "$113467$3" to lines matched by 
pattern "(^\s*\[\s*assembly\s*:\s*AssemblyVersionAttribute\s*\(\"[0-9\*]+\.[0-9\*]+\.)([0-9\*]+\.)([0-9\*]\"\)s*\])" 
 in the files matched by wildcard: **/AssemblyInfoVersion.cs...
 [14:28:44][File content replacer] Total files changed: 0.
 [14:28:44][File content replacer] No modifications were made: either no 
 text matching the pattern was found or the replaced text is the same as the 
 original

我希望将“ 1923”替换为“ 13468”。没什么。怎么了?

2 个答案:

答案 0 :(得分:2)

尝试 (^\s*\[\s*assembly\s*:\s*AssemblyVersionAttribute\s*\(\"[0-9\*]+\.[0-9\*]+\.)([0-9\*]+\.)([0-9\*]+\"\)s*\])

您的正则表达式模式中缺少最后一个+

答案 1 :(得分:1)

原因是由于打字错误,没有匹配项。检查此正则表达式:

(^\s*\[\s*assembly\s*:\s*AssemblyVersionAttribute\s*\(\"[0-9\*]+\.[0-9\*]+\.)([0-9\*]+\.)([0-9\*]*\"\)s*\])

我仅在最后一个* *之后加了星号“ [0-9\*]”。 然后匹配。