Loading ...
Sorry, an error occurred while loading the content.

Re: [NTB] find & replace with regular expressions

Expand Messages
  • Don - htmlfixit.com
    Hi again John, It does work on the sample you sent through a while ago on my end, so there is something just a tich off in transfer. Email me a direct sample
    Message 1 of 11 , Dec 21, 2005
    • 0 Attachment
      Hi again John,

      It does work on the sample you sent through a while ago on my end, so
      there is something just a tich off in transfer. Email me a direct
      sample of your file if you are willing.

      I agree with John, we should move over to the html list if we continue.
      I'll copy this over there. Are you a member of that group?

      Start with just a find command only, forget the replace for a minute.
      You need to un-check regex before copying it in, and then check regex
      once it is there. I'll still save you the $159 before we are done :-)

      Don
    • Don Strack
      ... Yes, I m also a member here. I sent you the (very large) file. Thanks for your help. Don Strack
      Message 2 of 11 , Dec 21, 2005
      • 0 Attachment
        --- In ntb-html@yahoogroups.com, "Don - htmlfixit.com" <don@h...> wrote:
        >
        > Hi again John,
        >
        > It does work on the sample you sent through a while ago on my end, so
        > there is something just a tich off in transfer. Email me a direct
        > sample of your file if you are willing.
        >
        > I agree with John, we should move over to the html list if we continue.
        > I'll copy this over there. Are you a member of that group?
        >
        > Start with just a find command only, forget the replace for a minute.
        > You need to un-check regex before copying it in, and then check regex
        > once it is there. I'll still save you the $159 before we are done :-)

        Yes, I'm also a member here. I sent you the (very large) file. Thanks
        for your help.

        Don Strack
      • Don - htmlfixit.com
        Don, In the example you gave me there are actually two returns after the td ... so this works: n {.*} n+ n n the + means one or more
        Message 3 of 11 , Dec 21, 2005
        • 0 Attachment
          Don,

          In the example you gave me there are actually two returns after the td ...
          so this works:
          </td>\n<td>{.*}\n+</td>\n</tr>\n<tr>

          the + means one or more returns.

          Other Don
        • Don Strack
          ... td ... ... I m now on a totally different computer, and that string does not work even in a simple search. Thanks for your help, but now I m really
          Message 4 of 11 , Dec 22, 2005
          • 0 Attachment
            --- In ntb-html@yahoogroups.com, "Don - htmlfixit.com" <don@h...>
            wrote:

            > In the example you gave me there are actually two returns after the
            td ...
            > so this works:
            >
            > </td>\n<td>{.*}\n+</td>\n</tr>\n<tr>
            >
            > the + means one or more returns.

            I'm now on a totally different computer, and that string does not work
            even in a simple search.

            Thanks for your help, but now I'm really confused. For those who are
            just joining us, I am looking to add a CSS class to the last column
            <td> of a five column table. This is part of my effort to make my web
            pages validate as XHTML. The table has so many rows (over 2550)that
            Dreamweaver chokes when I try to select the entire column and add a
            CSS style. So, I want to use NoteTab Pro, and a regular expression
            since the contents of each <td> varies. I am including the closing
            </tr> for this row and the opening <tr> for the next row to ensure
            that I am working only with the last column.

            Find:
            </td>
            <td>[whatever, whatever]
            </td>
            </tr>
            <tr>

            Replace:
            </td>
            <td class="wrap">[whatever, whatever]
            </td>
            </tr>
            <tr>

            Here is the web page, with the last column that does not wrap, but
            which I want to wrap to keep it inside of my 750px width:

            http://utahrails.net/all-time/up_2001-2005_renumbered-from.php

            Here is a page that does wrap:

            http://utahrails.net/all-time/classic-index.php

            Don Strack
          • Rudolf Horbas
            Hi Don, ... It wouldn t -- it s a regex, not a simple search string. (The regex above works on my machine for the given example.) Rudi
            Message 5 of 11 , Dec 22, 2005
            • 0 Attachment
              Hi Don,

              >></td>\n<td>{.*}\n+</td>\n</tr>\n<tr>

              > I'm now on a totally different computer, and that string does not work
              > even in a simple search.

              It wouldn't -- it's a regex, not a simple search string.

              (The regex above works on my machine for the given example.)

              Rudi
            • Don - htmlfixit.com
              ... The problem is obvious to me after getting your sample file. The pattern is different than what you are giving me. If you mail me the file (before
              Message 6 of 11 , Dec 22, 2005
              • 0 Attachment
                > I'm now on a totally different computer, and that string does not work
                > even in a simple search.
                >
                > Thanks for your help, but now I'm really confused. For those who are
                > just joining us, I am looking to add a CSS class to the last column
                > <td> of a five column table. This is part of my effort to make my web
                > pages validate as XHTML. The table has so many rows (over 2550)that
                > Dreamweaver chokes when I try to select the entire column and add a
                > CSS style. So, I want to use NoteTab Pro, and a regular expression
                > since the contents of each <td> varies. I am including the closing
                > </tr> for this row and the opening <tr> for the next row to ensure
                > that I am working only with the last column.

                The problem is obvious to me after getting your "sample" file. The
                pattern is different than what you are giving me. If you mail me the
                file (before adding the   stuff to it) I think I can fix you up.

                What is happening is that you have returns in the content in the td-/td
                tag. Because of that, it isn't being found with the line. You also
                often have two returns. The problem is that if you add multiple returns
                to the regex I gave you (a modification I didn't show you), then the
                regex gets greedy. I think the solution I would employ is to change the
                returns inside the td-/td sets to a unique character, then do the
                replace using the string we already have, then unreplace the unique
                characters assuming that you want the returns in there.

                Don
              • Don - htmlfixit.com
                ... Don, We really can do this. What I really need is your original unmodified file. The file that you posted (first one) has some class= wrap tags
                Message 7 of 11 , Dec 22, 2005
                • 0 Attachment
                  > Here is the web page, with the last column that does not wrap, but
                  > which I want to wrap to keep it inside of my 750px width:
                  >
                  > http://utahrails.net/all-time/up_2001-2005_renumbered-from.php
                  >
                  > Here is a page that does wrap:
                  >
                  > http://utahrails.net/all-time/classic-index.php
                  >
                  > Don Strack

                  Don,

                  We really can do this. What I really need is your original unmodified
                  file. The file that you posted (first one) has some class="wrap" tags
                  inserted, but not all of them.

                  Here are two samples from that code:
                  <tr>
                  <td>
                  DRGW 3103
                  </td>
                  <td>
                  GP40-2

                  </td>
                  <td>
                  UP 1356
                  </td>
                  <td>
                  19 Jan 2005
                  </td>
                  <td class="wrap"> 
                  </td>
                  </tr>
                  <tr>
                  <td>
                  DRGW 3104
                  </td>
                  <td>
                  GP40-2
                  </td>

                  <td>
                  UP 1355
                  </td>
                  <td>
                  1 Sep 2001
                  </td>
                  <td>
                  Other documents show a renumber date of 20 August 2001; the later date is
                  assumed to be a correction.</td>
                  </tr>

                  The reason it doesn't find this is because there is a return here:
                  <td>
                  Other documents show a renumber date of 20 August 2001; the later date
                  is[return/line feed/whatever]
                  assumed to be a correction.</td>

                  The regex would work if you took out that line feed.
                  <td>
                  Other documents show a renumber date of 20 August 2001; the later date
                  is[no line feed here -- could be a space]assumed to be a correction.</td>

                  I can automate this I am confident, but I just need the correct infomation.

                  Is all of this data in a database anyway? You are using PHP, why not
                  build your tables on the fly anyway? You can extract the info with a
                  clip and built it out too if you want static files.

                  Anyway, I remain ready to help but a "raw" file is what I need to get
                  this right.

                  Don
                • Don Strack
                  ... unmodified ... tags ... infomation. Thanks for all the help and comments. I was able to do what I wanted by using the regular expressions as provided in
                  Message 8 of 11 , Dec 22, 2005
                  • 0 Attachment
                    --- In ntb-html@yahoogroups.com, "Don - htmlfixit.com" <don@h...>
                    wrote:
                    > We really can do this. What I really need is your original
                    unmodified
                    > file. The file that you posted (first one) has some class="wrap"
                    tags
                    > inserted, but not all of them.

                    > I can automate this I am confident, but I just need the correct
                    infomation.

                    Thanks for all the help and comments. I was able to do what I wanted
                    by using the regular expressions as provided in EditPlus. Here is
                    the search string that worked:

                    (</td>)
                    (<td>)
                    (.*?)
                    (</td>)
                    (</tr>)
                    (<tr>)

                    Here is the replacement string that worked:

                    $1
                    <td class="wrap">
                    $3
                    $4
                    $5
                    $6

                    The parenthesis in the above search string, set each tag as its own
                    variable, which was to remain the same in the replace string. It was
                    the second variable - the <td>, or $2 - that I wanted to replace, to
                    contain a class for the <td> tag. It worked just fine on all four,
                    very large files.

                    I guess I was (and still am) confused by the flavor of regular
                    expressions used by NoteTab. It appears that the most referenced
                    site for regular expressions, and how they work, is www.regular-
                    expressions.info, and it was by using their own text editor
                    (EditPlus) that I was able to get my work done, after spending over
                    8 hours trying to get regex to work in NoteTab. That's 8 hours I'll
                    never get back. Oh well. That's kind of why I started using
                    Dreamweaver; it automated so many things that I have been doing by
                    hand in NoteTab that my productivity has gone way up.

                    I still like NoteTab, since nothing else works so well at modifying
                    html tags to be all lower case (and I still have a lot of files with
                    upper case tags). Plus, I have lots of NoteTab clips that I use
                    regularly. It's just that I was not able to get regular expressions
                    to work.

                    Thanks for your help.

                    Don Strack
                  • Paul Geiger
                    Message 9 of 11 , Dec 22, 2005
                    • 0 Attachment
                    • Don - htmlfixit.com
                      ... Every dog has it s day. Obviously Dreamweaver has some advantages, but it also couldn t handle something like this. In this case the failure wasn t
                      Message 10 of 11 , Dec 22, 2005
                      • 0 Attachment
                        > Oh well. That's kind of why I started using
                        > Dreamweaver; it automated so many things that I have been doing by
                        > hand in NoteTab that my productivity has gone way up.
                        Every dog has it's day. Obviously Dreamweaver has some advantages, but
                        it also couldn't handle something like this. In this case the failure
                        wasn't notetabs! Your sample didn't accurately represent the actual
                        data in your file. Notetab does use it's own brand of regex to be
                        honest (although you can easily use perl as well).

                        I have never wasted an hour in my life. I learn from everything I do,
                        so I don't mind having tried to help. If I had the right information,
                        we would have had this solved yesterday. Instead I still don't have the
                        information necessary to do it in notetab (a free / cheap / very
                        modestly) priced solution. As you now have a solution ... I guess I
                        won't worry about this one any longer.

                        Have a Merry Christmas!
                      • Don - htmlfixit.com
                        ... Here is the clip answer that works on the actual data file: http://htmlfixit.com/blog/index.php?p=329
                        Message 11 of 11 , Dec 24, 2005
                        • 0 Attachment
                          Rudolf Horbas wrote:
                          > Hi Don,
                          >
                          >
                          >>></td>\n<td>{.*}\n+</td>\n</tr>\n<tr>
                          >
                          >
                          >>I'm now on a totally different computer, and that string does not work
                          >>even in a simple search.
                          >
                          >
                          > It wouldn't -- it's a regex, not a simple search string.
                          >
                          > (The regex above works on my machine for the given example.)
                          >
                          > Rudi

                          Here is the clip answer that works on the actual data file:
                          http://htmlfixit.com/blog/index.php?p=329
                        Your message has been successfully submitted and would be delivered to recipients shortly.