I try to do substring against 1 long string and then want to put each sub string into a new line. For example, if I have a long string "1pxxxx2pxxx1pyyyyy", the result would be 3 lines as below.
1pxxxx2pxxx1pyyyyyIn my case, 1p and 2p are pre-defined keyword. I really appreciate any helps. Thank you.
- What would be the "rule" where to split your string into pieces? What have you tried so far? You know you are expected to make an own attempt to solve your problem.Olaf– Olaf2020-05-22 01:18:11 +00:00CommentedMay 22, 2020 at 1:18
- To achieve my goal, I tried to combine substring and carriage return but had no luck. I'll post my query next time.Iverson Wang– Iverson Wang2020-05-22 03:23:17 +00:00CommentedMay 22, 2020 at 3:23
1 Answer1
Use-split, thestring-splitting operator, with a positivelookahead assertion (more detailshere):
PS> '1pxxxx2pxxx1pyyyyy' -split '(?=1p|2p)' -ne ''1pxxxx2pxxx1pyyyyy Sign up to request clarification or add additional context in comments.
Comments
Explore related questions
See similar questions with these tags.