Build abbreviations for underscore separated strings

Build abbreviations for underscore separated strings

2

    Mar 29, 2012#1

    Hello, I need help with a macro please.
    I have lines with the character underscore [_]. I need to paste at the end of the line the first character follow by each character after an underscore like that:

    Before macro
    TEMPORAL_COMPORTAMIENTO_CAR
    TEMPORAL_FORMULAS_CAR
    TERMINALES_ATM_POS_TARJ
    TIPO_CAMBIOS_CONT
    TIPO_CHEQUES_CUE
    TIPO_COL_DET_GEN
    TIPO_COLUMNAS_GEN
    TIPO_COMP_CONT
    TIPO_FILAS_GEN
    TIPO_FORMULAS_CAR
    TIPO_GASTOS_CAJAS_CHICAS_CAJ
    TIPO_INGRESOS_RENTAS_PER

    After macro
    TEMPORAL_COMPORTAMIENTO_CAR=TCC
    TEMPORAL_FORMULAS_CAR=TFC
    TERMINALES_ATM_POS_TARJ=TAPT
    TIPO_CAMBIOS_CONT=TCC
    TIPO_CHEQUES_CUE=TCC
    TIPO_COL_DET_GEN=TCDG
    TIPO_COLUMNAS_GEN=TCG
    TIPO_COMP_CONT=TCC
    TIPO_FILAS_GEN=TFG
    TIPO_FORMULAS_CAR=TFC
    TIPO_GASTOS_CAJAS_CHICAS_CAJ=TGCCC
    TIPO_INGRESOS_RENTAS_PER=TIRP

    Thanks a lot for your help!

    6,675585
    Grand MasterGrand Master
    6,675585

      Mar 29, 2012#2

      Because of your detailed before and after example it was easy for me to write this little macro using tagged expressions within a loop to produce the required result.

      The macro property Continue if search string not found must be checked for this macro.

      InsertMode
      ColumnModeOff
      HexOff
      UnixReOff
      Top
      Find MatchCase RegExp "%^(?^)^(*_*^)$"
      Replace All "^1^2=^1"
      Loop
      Find MatchCase RegExp "%^(*^)_^(?^)^(*^)$"
      Replace All "^1!#!^2^3^2"
      IfNotFound
      ExitLoop
      EndIf
      EndLoop
      Find MatchCase "!#!"
      Replace All "_"

      The 2 occurrences of character sequence !#! in the macro can be replaced also by a single character like ! or # or & which surely never exists in the file to make this macro even faster as it already is.

      2

        Mar 29, 2012#3

        Mofi thank you very much!!!
        The macro is working!
        I will read about tagged expressions to learn about it.