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

Counting html tags

Expand Messages
  • John Shotsky
    I have a routine to count opening and closing html tags, such as and . It uses a loop and counter for each and then the counts are compared. On a large
    Message 1 of 5 , Nov 16, 2013
    • 0 Attachment

      I have a routine to count opening and closing html tags, such as <p> and </p>. It uses a loop and counter for each and then the counts are compared. On a large document, it takes minutes just for the counting, which is not acceptable. I'd like to find a method that does not use a loop to get the counts. I'm thinking along the lines of using 'getdoclist' to get each occurrence, then using the line count as the count. Not sure that will work, but the question I have is whether there is a fast way to count occurrences of tags like this without using loops. The documents can be over 100,000 lines long.

       

      Any thoughts?

      Thanks,
      John

       

    • Dave
      Hi Would these help if you put and in the search pattern and nothing in the replace string ?? ^$GetDocListAll( SearchPattern ; ReplaceString )$ then
      Message 2 of 5 , Nov 17, 2013
      • 0 Attachment
        Hi
        Would these help if you put <p> and </p> in the search pattern and nothing in the replace string ??
        then use
         
            THANKYOU DAVE M
        ----- Original Message -----
        Sent: Sunday, November 17, 2013 7:52 AM
        Subject: [Clip] Counting html tags

        I have a routine to count opening and closing html tags, such as <p> and </p>. It uses a loop and counter for each and then the counts are compared. On a large document, it takes minutes just for the counting, which is not acceptable. I'd like to find a method that does not use a loop to get the counts. I'm thinking along the lines of using 'getdoclist' to get each occurrence, then using the line count as the count. Not sure that will work, but the question I have is whether there is a fast way to count occurrences of tags like this without using loops. The documents can be over 100,000 lines long.

         

        Any thoughts?

        Thanks,
        John

         

      • John Shotsky
        Thanks, that helped, and I now have something working. ;The token variable is what to search for, set by a clip. ^!Set %Token%=
        Message 3 of 5 , Nov 17, 2013
        • 0 Attachment

          Thanks, that helped, and I now have something working.

           

          ;The token variable is what to search for, set by a clip.

          ^!Set %Token%=<p

          ^!SetListDelimiter ^p

          ^!Set %Items%=^$GetDocMatchAll("^%Token%")$

          ^!Set %Count%=^$StrCount("<";"^%Items%";False;False)$

           

          It is very fast. Takes under a second to do what looping takes a minute and 15 seconds to do.

          Regards,
          John
          RecipeTools Web Site: http://recipetools.gotdns.com/
          John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

           

          From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Dave
          Sent: Sunday, November 17, 2013 04:00
          To: ntb-clips@yahoogroups.com
          Subject: Re: [Clip] Counting html tags

           

           

          Hi

          Would these help if you put <p> and </p> in the search pattern and nothing in the replace string ??

          then use

           

              THANKYOU DAVE M

          ----- Original Message -----

          Sent: Sunday, November 17, 2013 7:52 AM

          Subject: [Clip] Counting html tags

           

          I have a routine to count opening and closing html tags, such as <p> and </p>. It uses a loop and counter for each and then the counts are compared. On a large document, it takes minutes just for the counting, which is not acceptable. I'd like to find a method that does not use a loop to get the counts. I'm thinking along the lines of using 'getdoclist' to get each occurrence, then using the line count as the count. Not sure that will work, but the question I have is whether there is a fast way to count occurrences of tags like this without using loops. The documents can be over 100,000 lines long.

           

          Any thoughts?

          Thanks,
          John

           

        • joy8388608
          If I understand correctly, you could use $strcount( searchstr ; $gettext$ ; I )$ without the other lines. I suspect it would be just as fast. Joy
          Message 4 of 5 , Nov 17, 2013
          • 0 Attachment
            If I understand correctly, you could use $strcount("searchstr";"$gettext$";"I")$ without the other lines. I suspect it would be just as fast. Joy
          • John Shotsky
            Yes, that works with my minor adjustments: ^!Set %Open%=^$strcount(
            Message 5 of 5 , Nov 17, 2013
            • 0 Attachment

              Yes, that works with my minor adjustments:

              ^!Set %Open%=^$strcount("<p";"^$gettext$";"I")$

               

              Thank you, that is exactly what I was looking for, and it is probably even faster than mine.

              Regards,
              John
              RecipeTools Web Site: http://recipetools.gotdns.com/
              John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

               

              From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of mycroftj@...
              Sent: Sunday, November 17, 2013 06:34
              To: ntb-clips@yahoogroups.com
              Subject: [Clip] RE: Counting html tags

               

               

              If I understand correctly, you could use $strcount("searchstr";"$gettext$";"I")$ without the other lines. I suspect it would be just as fast. Joy

            Your message has been successfully submitted and would be delivered to recipients shortly.