Hello
I woundered if someone could please give me some advice on the following.
Is there an easier way to achieve the following
$b = $null
$A = "AXA","BZB","CYC"
foreach ($element in $A)
{
switch -wildcard ($element)
{ "*X*" {$element = $element -replace "X","T";continue} }
[array]$b += $element
}
$A = $B
So basically I am looking for any element in Array $A which contains an "X" character and if seen replace the X with a T and put the results in Array B, so $B looks like this
ATA
BZB
CYC
Then, $A = $B makes $A the same as $B (e.g. my X has been replaced with T)
I was thinking may be I could use the $A -Contains operator using a wildcard or regex statement e.g. $A -contains *X* no joy.
I just wondered if there was a simpler way
Thanks All
Ernie