Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Splitting a String with a Multicharacter Delimiter

$
0
0

Hello,

I'm trying to split a string of text using a multicharacter delimiter, but the split method appears to only support a one character delimiter.  Is there a simple way to split using multiple characters?

Example:

My file contains this:  ISA*DATA*DATA*DATA*DATA*DATA~ISA*DATA*DATA*DATA*DATA~ISA*DATA*DATA~

I would need to split it on "ISA*".  Below is an example of the output when I try to just use the split method.  Any idea why I'm getting that output and what a better way to do it is?

$test = "ISA*DATA*DATA*DATA*DATA*DATA~ISA*DATA*DATA*DATA*DATA~ISA*DATA*DATA~"
$test2 = $test.split("ISA*")
$test2


D
T

D
T

D
T

D
T

D
T
~



D
T

D
T

D
T

D
T
~



D
T

D
T
~


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>