foreach ($line in $test) {
$line.GetType()
$newline = $line -split ("<.*?>") -split ("{.*?}") # remove html and css tags
$newline.GetType()
}
I came across this when trying to use the .Trim()
method on $newline
. It works, but the intellisense did not indicate that it would. I thought .Trim()
would only work on String Objects (BaseType:System.Object), but in this instance, it seems to work on String[] Objects as well (BaseType:System.Array).
$line.GetType()
returns
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String System.Object
$newline.GetType()
returns
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String[] System.Array
First off, I would like to know why my original string was converted to an array, assuming it's the return value of -split
... Is it now an array of characters? I am a little confused.
Secondly, if there is a good answer, why do the string methods work on what is technically an array?
Coming from Python and C/C++, thanks.