- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2017 02:33 AM
Hi,
I working on script to parse a powershell output.
I need to splint the value using empty new line as a separator.
I tried different options but nothing is working.
Please help
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2017 02:16 AM
Thanks for your response.
I made this to work, I splitted using the first string after the new line.
It worked now..
Thanks again
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2017 04:29 AM
Can you do it using a regular expression?
var s = "This is a test\nLine 1\n\nLine 2\n\n\nLine3";
var sArray = s.split(/\n{2,}/);
// sArray = ["This is a test\nLine 1", "Line 2", "Line 3"];
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2017 05:58 AM
Also, just to clarify, if you're using Powershell, you might be getting back \r\n instead of just \n. If so, just change your regular expression from:
/\n{2,}/
to:
/(\r\n){2,}/
To be honest, I haven't played with Powershell that much, so I'm not sure whether it uses old DOS-style line endings or UNIX-style line endings. Since it's Windows, I suspect the former. If one doesn't work, try the other.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2017 04:46 AM
In line w/ Dennis' response:
....<script> + \n + <script>...
The '\n\ should give you a line break
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2017 02:16 AM
Thanks for your response.
I made this to work, I splitted using the first string after the new line.
It worked now..
Thanks again