The UltraEdit regular expression search string
^p[~201
] means:
Find a
carriage return + line-feed on which next
single character is
not from
character set 012, i.e. is neither 0 nor 1 nor 2, and match (select) all three characters on a positive match.
That is obviously not the right search string for this task.
It is quite difficult to use UltraEdit regular expression engine to find characters
not followed by a specific string as this regular expression engine is not designed for such searches even on using a
tagged regular expression to keep parts of found string. UltraEdit and Unix regular expression engines are mainly designed for pure positive searches.
But this replace is no problem on using most powerful
Perl regular expression with back-reference by searching for
\r\n(?!201
)(.) and replacing all found occurrences with
\1. This expression searches for
carriage return + line-feed on which next there is
not the
string 201 by using a
negative look-ahead not selecting anything, and there is at least
1 character on next line
not being a newline character which is also matched and back-referenced in replace string with
\1 to keep this character on removing
carriage return + line-feed.
But even better is using Perl regular expression search string
\r\n(?!201
)(?=.) with an empty replace string which does not match (select) the character on next line. So it searches for
carriage return + line-feed on which next there is
not the
string 201 by using a
negative look-ahead not selecting anything, but there is next at least
1 character on next line
not being a newline character not being matched by using a
positive look-ahead not selecting anything.
You might think that
\r\n(?!201
) as search string and an empty replace string is enough and you are right. But please take into account that this search string removes also empty lines and the line termination at end of file if there is one at all. That's the reason why it is better to use
\r\n(?!201
)(?=.) to avoid the deletion of blank lines and
carriage return + line-feed at end of file.