Find and replace data in a specific text field

Find and replace data in a specific text field

3
NewbieNewbie
3

    Aug 10, 2006#1

    Hi New to this macro game, hope someone can help plz.

    I have a text file with around 5000 lines. I will use the example below to explain what I am upto....

    I am trying to find lines starting with AA then to look at column 50 and replace the 01 with 00

    Before

    AA 01
    AB 01

    After

    AA 00
    AB 00


    Any ideas?

    Thank-you

    Hunt

    6,675585
    Grand MasterGrand Master
    6,675585

      Aug 11, 2006#2

      I don't understand your example. Is only column 50 (or 51) of the line starting with AA set to 0 or also all following lines because AB line has also changed to 00.

      If only 01 in the line starting with AA must be set to 00, it can be done without a macro with following UltraEdit style regular expression replace:

      Find: %^(AA???????????????????????????????????????????????^)01
      Replace: ^100
      Best regards from an UC/UE/UES for Windows user from Austria

      3
      NewbieNewbie
      3

        Aug 11, 2006#3

        Hi thanks for the reply, sry the first example it was not great...


        I am looking for multiple strings.

        I wish to change for example the 01s when AA or AB is found at the start of the line. In reality I am going to be looking for about 50 combinations, so i believe a macro with a loop would help(problem is I dont have the skills to write one :cry: ).

        Before

        AA 01
        AA 01
        AA 01
        AA 01
        AB 01
        AB 01
        AB 01

        After

        AA 00
        AA 00
        AA 00
        AA 00
        AB 00
        AB 00
        AB 00


        Not sure what the ultra edit style is either........... omg

        Many thanks for your help
        8O

        6,675585
        Grand MasterGrand Master
        6,675585

          Aug 11, 2006#4

          See Advanced - Configuration - Search - Regular Expression Engine which engine/style you use for regular expression searches and replaces.

          The following macro solution needs the macro property Continue if a Find with Replace not found checked.

          You can read in my second post at multiple files conversions help how to create a new macro and paste the following code into it.

          InsertMode
          ColumnModeOff
          HexOff
          UnixReOff
          Top
          Find MatchCase RegExp "%^(AA???????????????????????????????????????????????^)01"
          Replace All "^100"
          Find MatchCase RegExp "%^(AB???????????????????????????????????????????????^)01"
          Replace All "^100"
          ... and so on for all your combinations

          Add UnixReOn or PerlReOn (v12+ of UE) at the end of the macro if you do not use UltraEdit style regular expressions by default - see search configuration. Macro command UnixReOff sets the regular expression option to UltraEdit style.

          Well, the 2 regex above could be also combined to a single one:

          Find MatchCase RegExp "%^(A[AB]???????????????????????????????????????????????^)01"
          Replace All "^100"

          See help of UltraEdit about the Find command and the Regular expressions to understand these regular expressions.
          Best regards from an UC/UE/UES for Windows user from Austria

          3
          NewbieNewbie
          3

            Aug 12, 2006#5

            Thank you....

            Worked a treat :P

            Excellent Work