locked
Best case scenario command to split 1 word into array. RRS feed

  • Question

  • Hello,

    I have code line:

    $Table = (((@($Web.ParsedHtml.getElementsByTagName("table")) | select-Object -ExpandProperty innerText).trim()).replace(" ","")).replace("DenmarkSwedenNorwayNorthernIrelandFinlandLithuania","") |  ConvertFrom-Csv -Delimiter ' ' -Header "SpareServers"

    Output:

    SpareServers                       
    ------------                       
    WK0442WK4555WK4755WK4766W22266W22244
    WK0443

    Which command in best practice  should i use to make result as :

    SpareServers                       
    ------------ 

    WK0442
    Wtttbr> Wvvvbr> ffff
    W222ggggg
    W22244hhhh
    thff


    • Edited by TechSpark0 Wednesday, December 13, 2017 8:29 PM
    Wednesday, December 13, 2017 2:53 PM

Answers

  • Hi,

    Try this:

    $SpareServers = $Table.SpareServers -split "(\w{6})"
    (untested)
    • Edited by TobyU Wednesday, December 13, 2017 3:09 PM typo
    • Marked as answer by TechSpark0 Wednesday, December 13, 2017 3:15 PM
    Wednesday, December 13, 2017 3:09 PM

All replies

  • Hi,

    Try this:

    $SpareServers = $Table.SpareServers -split "(\w{6})"
    (untested)
    • Edited by TobyU Wednesday, December 13, 2017 3:09 PM typo
    • Marked as answer by TechSpark0 Wednesday, December 13, 2017 3:15 PM
    Wednesday, December 13, 2017 3:09 PM
  • Hi,

    Try this:

    $SpareServers = $Table.SpareServers -split "(\w{6})"
    (untested)

    Thank you so much :)
    Wednesday, December 13, 2017 3:15 PM