RegExp in Macro failing

RegExp in Macro failing

9
NewbieNewbie
9

    Sep 15, 2005#1

    I have a text file with up to 100000 lines like the following:

    $P:U
    $A:A
    $C:Code_Opportunity
    $U:N
    $V:' '
    $P:U
    $A:A
    $C:Code_Ratings_Code
    $U:N
    $V:' '
    $T:CHAR(1)

    Each "tag" starts with "$" and ends with ":". They should be in groups of 6 lines, one each of: $P: $A: $C: $U: $V: $T: in a group.

    However, there may be some "$T:" tags missing (see the first group, above), so I want to parse the file and identify the missing "$T:" tags and insert them as "$T:<missing>".

    To make matters worse, I will also have to do the same for missing "$V:" tags...

    I tried the (Ultraedit style) Find RegExp "^$V:*^P%^$P:" but this finds every $V: tag. Also "^$V:*^P%^$P:" finds none.

    Hope the above is clear, but what am I doing wrong?

    TIA

    6,675585
    Grand MasterGrand Master
    6,675585

      Sep 15, 2005#2

      Use ^$V:*^p^$P:

      % (= start of line) can be only used once in the search string at begin of the search string. By specifying ^p you have already specified also start of next line. To see this, simply search for a single ^p and look where the cursor is now. It is not at the end of the line, it is at start of the next line.
      Best regards from an UC/UE/UES for Windows user from Austria

      9
      NewbieNewbie
      9

        Sep 15, 2005#3

        Thanks, Mofi - but this still does not work (copied and pasted from your reply)!

        It finds:

        $V:' '
        $T:CHAR(1)
        $P:U

        and I need to find:

        $V:' '
        $P:U
        $A:A

        6,675585
        Grand MasterGrand Master
        6,675585

          Sep 16, 2005#4

          You have found a bug within UltraEdit's regular expression. UltraEdit is selecting everything after second ^$ until a P: is found. If using ^$V:*^p^$*T: it finds

          $V:' '
          $P:U
          $A:A
          $C:Code_Ratings_Code
          $U:N
          $V:' '
          $T:

          and this is definitively not OK.

          I found a workaround for this bug - use ^$V:*^p^$*P:
          Best regards from an UC/UE/UES for Windows user from Austria

          9
          NewbieNewbie
          9

            Sep 16, 2005#5

            Thanks again Mofi - I guessed it had to be a bug & I'm mailing Ian and the Uedit team about it now.

            Your workaround works fine!
            But can you explain (why you think) it works, please?

            Regards
            Alan

            6,675585
            Grand MasterGrand Master
            6,675585

              Sep 16, 2005#6

              I have already sent an email about this problem to IDM support with a link to this forum topic and extra description.

              I inserted the * after second ^$ because * means any numbers of characters which includes also number 0. I also don't know, why UltraEdit searches for P: after second $ and ignoring all characters between the $ and P:. We have to wait for the answer of the IDM developers.
              Best regards from an UC/UE/UES for Windows user from Austria

              9
              NewbieNewbie
              9

                Sep 16, 2005#7

                OK Mofi.

                The good news is that I am now able to replace 4 loops in my original macro with 4 RegEX Find/Replace which works many times faster.

                I have another query with the macro which I'll post in the appropriate forum if I can't find an answer in previous posts.

                Thanks again for your time,
                Alan