How to find line break on which next line does not begin with a certain string?

How to find line break on which next line does not begin with a certain string?

1
NewbieNewbie
1

    Jan 30, 2018#1

    Hi!

    In the following file I need to remove the line break of the first line. I identify the line break that I want to remove with the search: ^p[~201]
    However in the replace I loose the 9. How can I just remove the line break without loosing the character 9?

    Thanks!

    Code: Select all

    20180116 130127|1371090980001292
    932
    20180112 090145|1454054354674649687
    20180112 090131|1454311214299978562
    20180112 100147||1454311168815072721

    11327
    MasterMaster
    11327

      Jan 30, 2018#2

      Find what:   \R(\d{3}\R)
      Replace with \1
      Regular Expressions: Perl
      It's impossible to lead us astray for we don't care even to choose the way.

      6,681583
      Grand MasterGrand Master
      6,681583

        Jan 30, 2018#3

        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.
        Best regards from an UC/UE/UES for Windows user from Austria