Splitting a string into separate variables

后端 未结 5 1788
死守一世寂寞
死守一世寂寞 2020-12-13 16:42

I have a string, which I have split using the code $CreateDT.Split(\" \"). I now want to manipulate two separate strings in different ways. How can I separate t

5条回答
  •  盖世英雄少女心
    2020-12-13 17:21

    It is important to note the following difference between the two techniques:

    $Str="This is the
    source string
    ALL RIGHT" $Str.Split("
    ") This is the (multiple blank lines) source string (multiple blank lines) ALL IGHT $Str -Split("
    ") This is the source string ALL RIGHT

    From this you can see that the string.split() method:

    • performs a case sensitive split (note that "ALL RIGHT" his split on the "R" but "broken" is not split on the "r")
    • treats the string as a list of possible characters to split on

    While the -split operator:

    • performs a case-insensitive comparison
    • only splits on the whole string

提交回复
热议问题