I have a very long text file that contains records of data in a two lines format. Is there a way to simply replace all "newlines" characters to a space using IDM UltraEdit?
Sample input record (two lines):
OPCODE { V { X1; }
W { all=set; } }
needs to be re-formatted into a single line
OPCODE { V { X1; } W { all=set; } }
I have tried using Ultraedit Find and Replace using a regular expression to catch the newline:
Regexp used: }[^n][ ]+W
Replace with: } W
But the result was (removing the white space characters before the second line)
OPCODE { V { X1; }
W { all=set; } }
I am using UltraEdit version 19.10.0.1016.
UltraEdit has 3 regular expression engines.
With the UltraEdit regular expression engine the search string can be either }[ ^t^r^n]+W
or shorter }[ ^t^p]+W
and the replace string is } W
.
With the Unix regular expression engine the search string is }[ \t\r\n]+W
and the replace string is also } W
.
And with the most powerful Perl regular expression engine you have several options:
The search string is \}[ \t\r\n]+W
and the replace string is also } W
.
}
must be escaped with a backslash in Perl regexp syntax in search string as otherwise the search string is invalid. This is most likely the fastest version.
The search string is \}\s+W
and replace string is } W
.
\s
matches any whitespace character which includes also the newline control characters carriage return and line-feed and others in text files not very often used whitespaces from Unicode table. This is most likely slower than first option as the number of characters defined by \s
is larger.
The search string is (?<=\})\s+(?=W)
and the replace string is just a single space character.
(?<=\})
is a positive look-behind for }
and (?=W)
is a positive look-ahead for W
. Look-behind and look-ahead make a search in general slower in comparison to a search avoiding it if that is possible.
And lots of other search/replace expressions.
The case-sensitivity is controlled by Match case option in Replace dialog.