I'm trying to spit the string with a delimiter, which is a string:
$string = "5637144576, messag<>est<<>>5637145326, 1<<>>5637145328, 0"
$separator = "<<>>"
$string.Split($separator)
As the result of splitting I get:
5637144576, messag
est
5637145326, 1
5637145328, 0
Instead of
5637144576, messag<>est
5637145326, 1
5637145328, 0
When I try to use overloaded split which accepts string[]:
$string = "5637144576, messag<>est<<>>5637145326, 1<<>>5637145328, 0"
$separator = @("<<>>")
$string.Split($separator)
But I get next error:
Cannot convert argument "0", with value: "System.Object[]", for "Split" to type "System.Char[]": "Cannot convert value "<<>>" to type "System.Char". Error: "String must be exactly one character long.""
Does someone knows how to split string by string?
See Question&Answers more detail:os