Sinner3107
Sinner3107

Reputation: 31

Splitting a string by "." doesn't work as expected in AzureDevOps Pipeline

I have this string:

$b = "20211118.8"

I want to get both values into an array, so I do this:

$b = $b -split '\D+' 

and get the expected result

$b[0] = 20211118
$b[1] = 8

However, if I let my build pipeline do the same thing it splits every digit into a separate index and I get this:

$b[0] = 2
$b[1] = 0
$b[2] = 2
...

Why is that and how do I fix it?

Upvotes: 0

Views: 1478

Answers (1)

Sinner3107
Sinner3107

Reputation: 31

I didn't get it to work like I wanted, but I achieved it like this:

$build,$revision = $buildnumber.split(".")

Now:

$build = 20211118
$revision = 8

Upvotes: 2

Related Questions