Create Version Text using Expressions

Hi,

i need to create a string like ‘2019.2 SP1 Build 37’. That is ‘major.minor SPrevision Build build’. However, there is a condition. If Revision equals zero, the string is simply ‘2019.2 Build 37’. I was not able to figure this out using the revised query expression engine introduced with 1.9.1. Is it possible to create such a string?

Thomas

Hi Thomas,

You could do this in one line using regular expressions with the Replace(pattern:string, replacement:string, ignoreCase:bool) function. e.g.

Set Build Version [2019.2 SP$Utils.GetString(%revision%).Replace("^0$$", "", false).Replace("^([1-9][0-9]*)$$", "SP$$1", false)$ Build $Build.BuildNumber$]

However, this is quite complex. You may find it easier to use If and Else actions. e.g.

If (%revision% Equals 0)
	Set Build Version [2019.2 Build $Build.BuildNumber$]
Else
	Set Build Version [2019.2 SP%revision% Build $Build.BuildNumber$]

Thanks Dave for your help!