I have been trying to figure out a REGEX used by TeamCity in the File Content Replacer build feature and understand the majority of what it does to get the build number from the AssemblyVersion string in my GlobalAssemblyInfo. However, the replace string is leaving me somewhat mistified.
The multiline regex pattern is:
(^\s*\[\s*assembly\s*:\s*((System\s*\.)?\s*Reflection\s*\.)?\s*AssemblyVersion(Attribute)?\s*\(\s*@?\")(([0-9\*])+\.?)+(\"\s*\)\s*\])
the replace string is:
$1\%build.number%$7
a full example is here: RegexStorm Tester
Essentially, what I get is a group, with "4 captures" (see $5 on the link), and I am trying to access the captures individually so that my replace string would be more like:
$1$5[0].$5[1].$5[2]\%build.number%$7
Meaning that the resulting AssemblyVersion then becomes 1.0.0.%build.number%.
Does anyone know if this is possible? Or do I have to use a different pattern in order to get this level of granularity?