Is this possible? Find X And Replace With X+1

Is this possible? Find X And Replace With X+1

7
NewbieNewbie
7

    Jan 11, 2006#1

    Hi,

    I was looking for a way to increase the numbers in an array via UE and stumbled upon, for the very first time mind you, Macros.

    This, to me, seemed to be the way to go, but even though I have the Regular Expression up and running there seems to be no way I can add 1 to the search result.

    Let me give an example:

    Code: Select all

    Here we have some code which all of a sudden contains an array a_xml_content(2)

    What I would like to do now is increase the array number so it turns out like this:

    Code: Select all

    Here we have some code which all of a sudden contains an array a_xml_content(3)


    I thought this would be quite easy seeing how much else these macros are able to do. But no :\

    I use the following Reg. Exp. to search for the array:

    Code: Select all

    a_xml_content(^(*^))
    Yeah not even that is very precise but it seems to be close enough.



    If any one would be able to lend a hand I would be very gratefull.


    Cheers
    bjawnie

    206
    MasterMaster
    206

      Jan 11, 2006#2

      The only way I know to do it is find the digit, then run a series of IfCharIs
      checks on it - IfCharIs 3 then change it to a 4, etc.

      Of course, this would get ugly if two or more digits might show up between the parentheses
      Software For Metalworking
      http://closetolerancesoftware.com

      7
      NewbieNewbie
      7

        Jan 11, 2006#3

        Hi mrainey56,

        Thanks for your prompt reply. Yeah I can see how that solution rapidly could result in quite a large Macro. Still I don't think the number will ever exceed 100 so it would be reasonable easy to mantain.

        Might I persuade you into giving an example as I am a complete ignorant of all that is Macros.

        Thanks


        Cheers
        bjawnie

        6,602547
        Grand MasterGrand Master
        6,602547

          Jan 11, 2006#4

          Because your example is similar to that one posted at Add prev/next links based on filename, I could quickly modify and improve my macro according to your needs. This macro will work for numbers 0 to 198.

          OverStrikeMode
          ColumnModeOff
          HexOff
          UnixReOff
          Loop
          Find RegExp "a_xml_content([0-9]+)"
          IfNotFound
          ExitLoop
          EndIf
          Key LEFT ARROW
          Key LEFT ARROW
          IfCharIs "0"
          "1"
          Else
          IfCharIs "1"
          "2"
          Else
          IfCharIs "2"
          "3"
          Else
          IfCharIs "3"
          "4"
          Else
          IfCharIs "4"
          "5"
          Else
          IfCharIs "5"
          "6"
          Else
          IfCharIs "6"
          "7"
          Else
          IfCharIs "7"
          "8"
          Else
          IfCharIs "8"
          "9"
          Else
          IfCharIs "9"
          "0"
          Key LEFT ARROW
          Key LEFT ARROW
          IfCharIs "("
          InsertMode
          Key RIGHT ARROW
          "1"
          OverStrikeMode
          Else
          IfCharIs "0"
          "1"
          Else
          IfCharIs "1"
          "2"
          Else
          IfCharIs "2"
          "3"
          Else
          IfCharIs "3"
          "4"
          Else
          IfCharIs "4"
          "5"
          Else
          IfCharIs "5"
          "6"
          Else
          IfCharIs "6"
          "7"
          Else
          IfCharIs "7"
          "8"
          Else
          IfCharIs "8"
          "9"
          Else
          IfCharIs "9"
          Key DEL
          InsertMode
          "10"
          OverStrikeMode
          EndIf
          EndIf
          EndIf
          EndIf
          EndIf
          EndIf
          EndIf
          EndIf
          EndIf
          EndIf
          EndIf
          EndIf
          EndIf
          EndIf
          EndIf
          EndIf
          EndIf
          EndIf
          EndIf
          EndIf
          EndIf
          EndLoop
          InsertMode
          UnixReOn

          Remove the last red command, if you use regular expression in UltraEdit style by default instead of Unix style.
          For UltraEdit v11.10c and lower see Advanced - Configuration - Find - Unix style Regular Expressions.
          For UltraEdit v11.20 and higher see Advanced - Configuration - Searching - Unix style Regular Expressions.
          Macro commands UnixReOn/UnixReOff modifies this setting.

          And don't forget to enable the macro property Continue if a Find with Replace not found.
          Best regards from an UC/UE/UES for Windows user from Austria

          7
          NewbieNewbie
          7

            Jan 11, 2006#5

            Hi Mofi,

            Excellent work. I really appreciate you taken off some time to help me out and then on top of that coming up with the correct code that works like a charm :)

            Thanks

            206
            MasterMaster
            206

              Jan 11, 2006#6

              You're a good man Mofi.


              Mike
              Software For Metalworking
              http://closetolerancesoftware.com

              344
              MasterMaster
              344

                Jan 11, 2006#7

                You are right. But don't overpraise him. He might get lazy eventually ;-)))

                rds
                Bego
                Normally using all newest english version incl. each hotfix. Win 10 64 bit