How to replace a word with a different set of words

How to replace a word with a different set of words

1
NewbieNewbie
1

    Apr 26, 2009#1

    Can this be done?
    ----------------
    test example text looks like this
    test whatever text is this
    test3 Blahh
    test text looks this
    test2 Blah
    ----------------
    "test" should be replaced by "one" and "two" so that the final text looks like:
    "test2" should be replaced by "uno" and "dos" and "treis"
    "test3" should be replaced by "xx"

    ----------------
    one example text looks like this
    two whatever text is this
    xx Blahh
    one text looks this
    uno Blah
    ----------------

    this should be done from the beginning to the end of the textfile 1x. It could appear that a "testx" may not appear in the file. It should not stop at this point.


    Thanx alot

    6,686585
    Grand MasterGrand Master
    6,686585

      Apr 27, 2009#2

      Looks similar to Replace line after line, is this somehow possible and therefore I suggest to adapt the macro posted there to your word replacing need. How exactly the macro will look depends on the second file with the word sets. For example if the second file with the words to search for and replace with looks like this:

      Code: Select all

      !test
      one
      two
      !test2
      uno
      dos
      treis
      !test3
      xx
      the following macro would do the job. The macro property Continue if search string not found must be checked for this macro.

      InsertMode
      ColumnModeOff
      HexOff
      UnixReOff
      SelectAll
      Clipboard 9
      Copy
      NextWindow
      Top
      Paste
      IfColNumGt 1
      "
      #
      "
      Else
      "#
      "
      EndIf
      Top
      Loop 0
      IfCharIs "#"
      ExitLoop
      EndIf
      IfCharIs "!"
      Key RIGHT ARROW
      SelectWord
      Cut
      DeleteLine
      EndIf
      SelectWord
      Find MatchCase MatchWord "^c"
      Replace "^s"
      IfNotFound
      Top
      StartSelect
      Find RegExp Select "%[!#]"
      Key HOME
      Delete
      EndSelect
      Else
      Top
      DeleteLine
      EndIf
      EndLoop
      DeleteLine
      ClearClipboard
      Clipboard 0
      Best regards from an UC/UE/UES for Windows user from Austria