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

Re: [NTB] Help with regex... removing some html tags

Expand Messages
  • Don Daugherty
    The following two clips below, beginning with H=..., can be called from another clip by the following example calls: This one does what you want: ^!Clip
    Message 1 of 3 , Aug 6 12:04 PM
      The following two clips below, beginning with H=..., can be called from
      another clip by the following example calls:

      This one does what you want: ^!Clip "StripDoubleTag" script

      These two are related clips that strip tags but not the stuff between the
      opening and closing clips:
      ^!Clip "StripTag" FONT
      ^!Clip "StripTag" /FONT

      Looking at the StripDoubleTag clip you see that a single RegExp won't do the
      whole job because the present RegExp engine is "greedy."

      H="_StripDoubleTag"
      ^!Set %Tag%=^&
      ^!Jump Text_Start
      :Tag
      ^!Jump Text_Start
      ^!Find "<^%Tag%" TIS
      ^!IfError End
      ^!Jump Select_Start
      ^!Set %From%=^$GetRow$:^$GetCol$
      ^!Find "</^%Tag%>" TI
      ^!Jump Select_End
      ^!Set %To%=^$GetRow$:^$GetCol$
      ^!SetCursor ^%From%
      ^!SelectTo ^%To%
      ^!InsertText ^%Empty%
      ^!GoTo Tag
      :End

      H="_StripTag"
      ^!Jump Text_Start
      ^!Replace "<^&[^>]*>" >> "" RATIS
      :End

      > Each javascript has:
      > <script
      > every possible character and line feed combination
      > </script>
      >
      > Using the following statement:
      > (<script\a+(</script>))
      >
      > It finds the first occurrence of <script and the very last occurrence
      > of </script>. It never finds </script> tags that fall in-between.

      This is the "greedy" behavior!

      >Of course, it also selects other tags that I need to keep when it only
      > grabs the last </script>.
    • Don Daugherty
      Please excuse my replying to this topic on this list. Any subsequent discussion involving my post should be don on the Clips list. Sorry!
      Message 2 of 3 , Aug 6 12:09 PM
        Please excuse my replying to this topic on this list. Any subsequent
        discussion involving my post should be don on the Clips list. Sorry!
      • mbl60181
        ... So that s the problem... Thanks for the help!
        Message 3 of 3 , Aug 6 2:14 PM
          > Looking at the StripDoubleTag clip you see that a
          > single RegExp won't do the whole job because the
          > present RegExp engine is "greedy."

          So that's the problem... Thanks for the help!
        Your message has been successfully submitted and would be delivered to recipients shortly.