Please make sure to read the edits before using the regex.
Ok, here's a regular expression that works. I made a read file and a write file that reads stdout of the previous task whose value is:
{REGEX(Replace|{TASK(PrevTask,StdOut)}|(.*)(\r)(.*)|$1$3)}
The regular expression makes 3 "remembered" groups of the line which are indicated by being surrounded by parentheses. The first is the part of the line before the carriage return, the second is the carriage return, the third the rest of the line after the carriage return. The entire line is then replaced with the first and third remembered groups, effectively deleting the second one, which contains only the carriage return. Note in the write file task I set the line break character to LF.
You don't want to replace the carriage return with a NULL, but delete it. An embedded NULL will cause unexpected results as who knows how some string functions will handle that. I suspect they would treat the NULL as the end of the string, causing it to not see the line feed maybe. Don't take the chance.
EDIT
This has the same effect and is somewhat simpler. It basically only keeps the part of the line before the carriage return. Make sure to select LF as the line break character.
{REGEX(Replace|{TASK(PrevTask,StdOut)}|(.*)(\r.*)|$1)}
IMPORTANT EDIT 1/17/2017
I just had a realization while trying to figure out what was going on in my post #6 below that is important to understand here for how my answer is applied.
I will chalk it up to being a new user and still learning but I want to make sure it is clear for future searchers that may see this thread.
I had originally assumed the stdout from the previous task was being looked at line-by-line here but my realization is when the write file task is reading the stdout from the read file task, it is looking at the stdout as one big multi-line string , not line-by-line. This affects the logic of the regular expression.
The regex applied still works here, but it is not applied on a line-by-line basis as I originally thought, but for each OCCURRENCE of the pattern within the entire output. It happens to still work for the pattern in this case, but the distinction is important to understand if you apply this technique to other problems. Also consider that effectively the entire file is operated on at once which may have memory usage implications, I don't know.
Gary
Edited by user
2017-01-17T19:40:27Z
|
Reason: Not specified