4 Replies Latest reply on Mar 26, 2012 5:02 AM by jocstone_me

    GREP find & replace question

    jocstone_me Level 1

      hi,

      here is my problem,

      I have a huge list with names, each name is one or more words devided by a space,

      each name is devided with a tab.

      now I want to do the following, every 7th tab should change into a return.

       

      so finaly I will end up with a list with 7 names in a row.

       

      now it looks like this:

       

      name[tab]name[tab]name name[tab]name[tab]name name name[tab]name[tab]name[tab]name[tab]name[tab]name[tab]name[tab]name[tab]name[tab]name[tab ]name[tab]name[tab]

       

      this should it be:

       

      name[tab]name[tab]name name[tab]name[tab]name name name[tab]name[tab]name[ENTER]

      name[tab]name[tab]name[tab]name[tab]name[tab]name[tab]name[ENTER]

      name[tab]name[tab]

       

      thanks!!

        • 1. Re: GREP find & replace question
          [Jongware] Most Valuable Participant

          That's perfectly doable! This ought to work: search for

           

          (([^\t]+\t){6}[^\t]+)\t

           

          and replace with

           

          $1\r

           

          It looks for any sequence of any number of not-a-tab, followed by a tab, all in a group of 6, and followed by yet another sequence of not-a-tab characters, and then one final tab that's going to be the little piggy that's not going to the market today.

          • 2. Re: GREP find & replace question
            jocstone_me Level 1

            you are te greatest!

            it works!

             

            so [^\t] means any character, not tab?

            • 3. Re: GREP find & replace question
              [Jongware] Most Valuable Participant

              That is correct.

               

              [...] defines a character set -- any single character or character code in it is valid, as a single character. The canonical example is "h[auo]t", which matches "hat", "hot", and "hut" but not "hit", "het", or "haut".

               

              In normal use the character '^' is the code for "start of paragraph", but it looses this magical property inside a [...] set -- most other special codes do. When used as the very first code inside the character set definition it reverses the regular meaning.

              Thus, "h[^auo]t" will match "hit" and "het", as well as "hAt", "h?t", "hät", "h䰫t" -- etc.; really anything except the three in the example above.

               

              In your case, I used "[^\t]+" as a fast way to indicate "everything in between tabs".

              • 4. Re: GREP find & replace question
                jocstone_me Level 1

                now I get it...

                I absorbe this into my brain...

                in one click now my 5331 names are divided in 7 columns (don't ask why ) and thats what I wanted!

                 

                thank you!