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

Need help with RegExpr for Find and Replace in Table attributes

Expand Messages
  • Wiz Feinberg
    Hi y all! I am correcting invalid html codes for a new client whose website design revolves around multiple nested tables. While running HtmlTidy it informed
    Message 1 of 3 , Apr 4, 2006
    • 0 Attachment
      Hi y'all!

      I am correcting invalid html codes for a new client whose website
      design revolves around multiple nested tables. While running HtmlTidy
      it informed me that none of the tables contains a summary attribute,
      that some contain an invalid height attribute, and others contain a
      proprietary background attribute.

      I need a RegExpr to use in a search and replace box to run on each of
      these problems, to fix them on an entire page. So far, all I came up
      with for the find field is:
      <table\s.*>
      Which finds and highlights the entire table tag.

      I don't know how to address the replace field so that it will include
      everything that is inside the existing tag, and allow me to append or
      remove or alter one attribute as needed.

      For example, here is a table tag that I need to alter:

      <TABLE height="100%" cellSpacing=0 cellPadding=0 width=650
      align=center background=images/bg.gif border=0>

      In this instance I will need to remove the entire height attribute,
      convert the background attribute to an inline style, and add a summary
      attribute. I also want to make all attributes lowercase. The finished
      tag would be like this:

      <table cellspacing="0" cellpadding="0" width="650" align="center"
      style="background-image:url(images/bg.gif)" border="0" summary="Layout
      table">

      On other tables I only need to add the summary to the end of the
      attributes.

      Any help would be appreciated. If I learn the proper way to include
      the existing elements I can figure out how to add new ones or replace
      unwanted ones.

      Wiz
    • abairheart
      ... of ... include ... I d suggest you look up HTML clip code in the NoteTab help to begin with. Combined with Find, and select, you could find the entire tag
      Message 2 of 3 , Apr 6, 2006
      • 0 Attachment
        --- In ntb-clips@yahoogroups.com, "Wiz Feinberg" <wizcrafts@...>
        wrote:
        >


        >
        > I need a RegExpr to use in a search and replace box to run on each
        of
        > these problems, to fix them on an entire page. So far, all I came up
        > with for the find field is:
        > <table\s.*>
        > Which finds and highlights the entire table tag.
        >
        > I don't know how to address the replace field so that it will
        include


        > <TABLE height="100%" cellSpacing=0 cellPadding=0 width=650
        > align=center background=images/bg.gif border=0>
        >



        I'd suggest you look up HTML clip code in the NoteTab help to begin
        with.

        Combined with Find, and select, you could find the entire tag and
        extract a given attribute without using a regexp.

        THEN you could use RegExp in an IfMatch command to extract the
        desired value, and reassemble the netire tag and paste it back over
        the selected tab.

        There are a lot of details in this, and your going to have to deal
        with them individually.


        Abair.
      • Don Daugherty
        ... Here are a few ideas, indicating the Clip commands you would want to read-up on in order to automate your task. To select the entire tag us
        Message 3 of 3 , Apr 16, 2006
        • 0 Attachment
          Wiz Feinberg wrote:

          >For example, here is a table tag that I need to alter:
          >
          ><TABLE height="100%" cellSpacing=0 cellPadding=0 width=650
          >align=center background=images/bg.gif border=0>
          >
          >In this instance I will need to remove the entire height attribute,
          >convert the background attribute to an inline style, and add a summary
          >attribute. I also want to make all attributes lowercase. The finished
          >tag would be like this:
          >
          ><table cellspacing="0" cellpadding="0" width="650" align="center"
          >style="background-image:url(images/bg.gif)" border="0" summary="Layout
          >table">
          >
          >On other tables I only need to add the summary to the end of the
          >attributes.
          >
          >
          Here are a few ideas, indicating the Clip commands you would want to
          read-up on in order to automate your task.

          To select the entire <table ...> tag us this:
          ^!Find "<table" IS
          ^!Select HtmlTag
          Having select the tag, you can perform the requred search/replace
          commands, for example
          ^!Replace "height=[^\s]+\s" >> "" RHIS
          Notes:
          1. The R indicates the use of a regular expression.
          2. The \s stands for a space;
          3. The cryptic construction [^\s] means any character BUT the space;
          4. The + means one or more instances of the preceding character.
          5. Thus the ^!Replace command looks within the selected text for
          "height=" followed immediately followed by one or more non-space
          character, such as "100%", and a space, and it replaces the combination
          with a null string ("").

          To add a summary at the end use something like
          ^!Replace ">" >> "summary="whatever is appropriate">" HS
        Your message has been successfully submitted and would be delivered to recipients shortly.