Pls, how works split

Hello to you !

cls

$string = @(
“Adolf-Kolping-Weg, KG Mühlau (Mühlau-Dorf)”
“Adolf-Pichler-Platz, KG Innsbruck (Innenstadt)”
“Ahornhof, KG Pradl”
“Aldranser Straße, KG Amras”
“Algunder Straße, KG Amras”)

foreach ($strings in $string[-1])
{
$splitArray = $string.Split(“,”) | Format-Table -AutoSize
}
$splitArray

Arnold,

When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in PowerShell.org 1 <---- Click :point_up_2:t4: :wink:

( !! Sometimes the preformatted text button hides behind the settings gear symbol. :wink: )

… now … to your question … what is it actually what you’re trying to achieve?

In generall I’d recommend to stick with the PowerShell operator -split instead of the string mehtod .split()

'Ahornhof, KG Pradl' -split ','

outputs:

Ahornhof 
 KG Pradl

… but I doubt that this is what you’re looking for, right?

I could imagine that you’re actually looking for something like this:

$string = @'
Adolf-Kolping-Weg, KG Mühlau (Mühlau-Dorf)
Adolf-Pichler-Platz, KG Innsbruck (Innenstadt)
Ahornhof, KG Pradl
Aldranser Straße, KG Amras
Algunder Straße, KG Amras
'@

$string | ConvertFrom-Csv -Header 'Name', 'Ort'

… outputs this:

Name                Ort
----                ---
Adolf-Kolping-Weg   KG Mühlau (Mühlau-Dorf)
Adolf-Pichler-Platz KG Innsbruck (Innenstadt)
Ahornhof            KG Pradl
Aldranser Straße    KG Amras
Algunder Straße     KG Amras

If not you may explain more detailed what you’re actually trying to achieve.

Hello Sir
Many thnks for your Help.

Yes that wath i need
Great help
Arnold

Hello
I m sorry
I will do !