Tapatalk

Expression for Line Feed

Expression for Line Feed

2
NewbieNewbie
2

    Jun 26, 2015#1

    I need to replace the characters >**< that are followed a linefeed with double quotations and a linefeed.

    Could someone tell me the expression

    I am getting an error message with >**</n

    Thanks.

    115
    Power UserPower User
    115

      Jun 26, 2015#2

      What you use depends on the REGEX engine you select for the replace and what kind of line terminators are in the document (determined by the host system or by the software used).
      In the Find and Replace window you make sure Regular Expressions is checked and the selection box below it has the engine you want to use.
      Look at the status line at the bottom of the UltraEdit Window following the line and column numbers to see the terminator type in use.

      Unix documents have a linefeed as terminator.
      DOS documents have a carriage return plus linefeed as terminator.
      MAC documents have a carriage return as terminator.

      If using the UltraEdit REGEX you use ^n for linefeed, ^r for a carriage return, or ^p for both
      If using the Perl REGEX then you use \n for a linefeed, \r for a carriage return, or both together \r\n
      If using the Unix REGEX then you use \n for a linefeed, \r for a carriage return, \r\n or \p for both

      Now the rest of the characters you are searching for are not ordinary characters so that part of the string has to be changed too.
      The > and < can be treated as normal text.

      If you use the Unix or Perl REGEX engine the * has the special meaning of zero or more occurrences of the previous character while in the UltraEdit REGEX engine the * means any character any number of times (except newlines). So to match a real * the special meaning has to be turned off.
      Using the UltraEdit REGEX, precede each * with the ^ character.
      Using Perl/Unix REGEX, precede each * with the \ character.

      UltraEdit Find string on a Unix file would be >^*^*<^n and the replace string would be ""^n

      Unix or Perl Find string would be >\*\*<\n and the replace string would be ""\n

      6,685587
      Grand MasterGrand Master
      6,685587

        Jun 27, 2015#3

        Mick, excellent explained. Thank you.

        bmichaelh, the only regular expression engine showing an error message because of an invalid search string is the Perl regular expression engine and therefore I know that you have selected Perl as regular expression engine. The Perl regexp search string is invalid because of **. Two 0 or more times in series is an error. For the solution read the excellent reply by Mick above.

        By the way: You could also use >^*^*<$ (UE) or >\*\*<$ (Unix/Perl) as search string and "" as replace string to replace literal string >**< at end of a line with two double quotes. Note: Only Perl engine interprets $ also as end of file if last line of file has no line terminator. UltraEdit and Unix engine require on usage of $ that also the last line of the file has a line termination.
        Best regards from an UC/UE/UES for Windows user from Austria

        2
        NewbieNewbie
        2

          Jun 30, 2015#4

          Thanks for your help.

          That worked. It helped me cleanup some csv files.