add a space between bytes except for the last byte

add a space between bytes except for the last byte

2
NewbieNewbie
2

    Oct 09, 2008#1

    Test data:

    80040400062CECCCFF00000001D73B00

    Desired result:

    80 04 04 00 06 2C EC CC FF 00 00 00 01 D7 3B 00

    Note that there should not be a space at the end of the line.

    The following simple tactics does not make me happy:

    Find What: (\w{2})
    Replace With: $1
    (Note that there is a space after $1).

    So the real challenge is: how do you implement the logic "the byte beofre new lines".

    Thanks for your help in advance.

    Ming Wu

    236
    MasterMaster
    236

      Oct 09, 2008#2

      (\w{2})(?![\r\n])

      matches two characters unless they are followed by a newline character.

      262
      MasterMaster
      262

        Oct 09, 2008#3

        Just add a positive lookahead to your regexp:

        (\w{2})(?=\w)

        ie. only match the two next word characters if succeeded by a word character

        replace \1<blank>

        re-edit: Oops. Simultaneous posting. But mine will also work if the last line in the file is not followed by a single newline ;-)

        236
        MasterMaster
        236

          Oct 09, 2008#4

          Unless mingwu is using an older UE version (pre-14, I think) which still has the positive lookahead bug :)

          2
          NewbieNewbie
          2

            Oct 19, 2008#5

            Thanks guys.

            Both version worked perfectly.

            There is no bug at all, since I do not need to add a blank for a byte which is immediately followed by a newline.