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

Script to strip scripts from HTML

Expand Messages
  • rdeckard1ca
    I want to create a script to strip javascripts from saved web pages. Essentially then, I want to search for , and everything in between and
    Message 1 of 12 , Feb 1, 2002
    • 0 Attachment
      I want to create a script to strip javascripts from saved web pages.
      Essentially then, I want to search for <SCRIPT>, </SCRIPT> and everything in between and replace it with a blank space. Using FIND and REPLACE though, I can't figure out how to use regular expressions to identify this group of words as a block. The help file isn't very good at illuminating how this might be accomplished.

      Suggestions?
    • Jody
      Hi rdeckard1ca, ... It is easier for me to do a Clip than to use RegExp. So, H=Remove javascript ; jody
      Message 2 of 12 , Feb 1, 2002
      • 0 Attachment
        Hi rdeckard1ca,

        >I want to create a script to strip javascripts from saved web
        >pages. Essentially then, I want to search for <SCRIPT>, </SCRIPT>
        >and everything in between and replace it with a blank space.
        >Using FIND and REPLACE though, I can't figure out how to use
        >regular expressions to identify this group of words as a block.
        >The help file isn't very good at illuminating how this might be
        >accomplished.

        It is easier for me to do a Clip than to use RegExp. So,

        <--- Copy below this line --->
        H=Remove javascript
        ; jody http:/www.notetab.net
        ^!SetScreenUpdate Off
        ^!Jump 1
        ^!Find "<script" S
        ^!IfError End
        ^!Jump Select_Start
        ^!Set %Start%=^$GetRow$:^$GetCol$
        ^!Find "</script>" S
        ^!Jump Select_End
        ^!SelectTo ^%Start%
        ^!InsertText ^%Empty%

        <--- Copy above this line, right --->
        <--- click over a Library, and --->
        <--- choose "Add from Clipboard" --->

        Happy Clip'n!
        Jody

        http://www.notetab.net

        Subscribe, UnSubscribe, Options
        mailto:Ntb-Clips-Subscribe@yahoogroups.com
        mailto:Ntb-Clips-UnSubscribe@yahoogroups.com
        http://groups.yahoo.com/group/ntb-clips
      • silvermoonwoman2001
        ... everything in between and replace it with a blank space. Using FIND and REPLACE though, I can t figure out how to use regular expressions to identify this
        Message 3 of 12 , Feb 1, 2002
        • 0 Attachment
          --- In ntb-clips@y..., "rdeckard1ca" <rdeckard_@e...> wrote:
          > I want to create a script to strip javascripts from saved web pages.
          > Essentially then, I want to search for <SCRIPT>, </SCRIPT> and
          everything in between and replace it with a blank space. Using FIND
          and REPLACE though, I can't figure out how to use regular expressions
          to identify this group of words as a block. The help file isn't very
          good at illuminating how this might be accomplished.
          >
          > Suggestions?

          I couldn't live without regular expressions. This should do what you
          want:

          ^!Replace \<SCRIPT\>.*\<\/SCRIPT\> \s ACIWRS
        • Jody
          Hi silvermoonwoman2001, ... I always have a problem with them being too greedy, or at least it takes me a number of trial and errors to get it right. BTW, it
          Message 4 of 12 , Feb 1, 2002
          • 0 Attachment
            Hi silvermoonwoman2001,

            >I couldn't live without regular expressions. This should do what
            >you want:
            >
            >^!Replace \<SCRIPT\>.*\<\/SCRIPT\> \s ACIWRS

            I always have a problem with them being too greedy, or at least
            it takes me a number of trial and errors to get it right.

            BTW, it is best to use the following format on the lists, because
            of eMail programs and perhaps yahoo turning tabs into spaces.

            ^!Replace "<script>.*<\/script>" >> "" RSI


            Happy Clip'n!
            Jody

            http://www.notetab.net

            Subscribe, UnSubscribe, Options
            mailto:Ntb-Clips-Subscribe@yahoogroups.com
            mailto:Ntb-Clips-UnSubscribe@yahoogroups.com
            http://groups.yahoo.com/group/ntb-clips
          • rdeckard1ca
            silvermoonwoman, Jody: Thanks for suggestions, will try both.
            Message 5 of 12 , Feb 1, 2002
            • 0 Attachment
              silvermoonwoman, Jody:
              Thanks for suggestions, will try both.
            • hpaulissen
              ... you ... Make that a* and it will find anything between the tag-lines on more then one line... HTH, Hugo
              Message 6 of 12 , Feb 3, 2002
              • 0 Attachment
                >
                > I couldn't live without regular expressions. This should do what
                you
                > want:
                >
                > ^!Replace \<SCRIPT\>.*\<\/SCRIPT\> \s ACIWRS

                Make that \<SCRIPT\>\a*\<\/SCRIPT\> and it will find anything between
                the tag-lines on more then one line...

                HTH,

                Hugo
              • ...Tyrell...
                ... _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com
                Message 7 of 12 , Feb 3, 2002
                • 0 Attachment
                  > > I couldn't live without regular expressions. This should do what you
                  > > want:
                  > >
                  > > ^!Replace \<SCRIPT\>.*\<\/SCRIPT\> \s ACIWRS
                  >
                  >Make that \<SCRIPT\>\a*\<\/SCRIPT\> and it will find anything between
                  >the tag-lines on more then one line...

                  make that \<SCRIPT\a*\<\/SCRIPT\> and you find about 800% more script
                  sections ;-)

                  most webpages today don't just use <SCRIPT> anymore
                  but something more like <script language="JavaScript">



                  .?. anyone that might have some use for a HTML tag scanner .?.
                  you give it a document to process.
                  It give you the tag names used in that document, split in two ( | array) lists,
                  one for single tags, the one's without a closing partner like IMG
                  and one for dual tags, with closing partner BODY

                  Cheers
                  ...Tyrell...


                  _________________________________________________________
                  Do You Yahoo!?
                  Get your free @... address at http://mail.yahoo.com
                • Alec Burgess
                  ... Problem is that AFAIK that expression will not do what s wanted if there is more than one .... pair in the document. It will find from
                  Message 8 of 12 , Feb 3, 2002
                  • 0 Attachment
                    > > I couldn't live without regular expressions. This should do what
                    > you
                    > > want:
                    > >
                    > > ^!Replace \<SCRIPT\>.*\<\/SCRIPT\> \s ACIWRS
                    >
                    > Make that \<SCRIPT\>\a*\<\/SCRIPT\> and it will find anything between
                    > the tag-lines on more then one line...

                    Problem is that AFAIK that expression will not do what's wanted if there
                    is more than one <SCRIPT> .... </SCRIPT> pair in the document. It
                    will find from the first <SCRIPT> to the last </SCRIPT>.

                    It would be really nice if Eric could find a more powerful regexp engine
                    to put in V5!


                    Regards ... Alec
                    ----- Original Message -----
                    From: "hpaulissen" <h.paulissen@...>
                    To: <ntb-clips@yahoogroups.com>
                    Sent: 03 February, 2002 17:41
                    Subject: [Clip] Re: Script to strip scripts from HTML
                  • Jody
                    Hi ...Tyrell..., Sounds like a neat toy. ;) How about uploading it. If you do not have a server setup, you can upload to the file area for the HTML or Clips
                    Message 9 of 12 , Feb 3, 2002
                    • 0 Attachment
                      Hi ...Tyrell...,

                      Sounds like a neat toy. ;) How about uploading it. If you do
                      not have a server setup, you can upload to the file area for the
                      HTML or Clips group at yahoo.

                      >.?. anyone that might have some use for a HTML tag scanner .?.
                      >you give it a document to process.
                      >It give you the tag names used in that document, split in two ( | array) lists,
                      >one for single tags, the one's without a closing partner like IMG
                      >and one for dual tags, with closing partner BODY
                    • Jody
                      Hi Alec and Others, ... Eric has tried some of them over the years that, by popular demand, were a more powerful regexp engine. I ve seen that quote 50
                      Message 10 of 12 , Feb 3, 2002
                      • 0 Attachment
                        Hi Alec and Others,

                        >It would be really nice if Eric could find a more powerful regexp engine
                        >to put in V5!

                        Eric has tried some of them over the years that, by popular
                        demand, were "a more powerful regexp engine." I've seen that
                        quote 50 times if I've seen it once. One problem use to be that
                        "NoteTab" was always greedy; there was no way to prevent it. So,
                        currently, it is not greedy, only does a line at a time, unless
                        you use something like above (\a). Every RegExp engine he has
                        tried is buggy and has its pros and cons from what I can see via
                        the lists and support mail. It seems like Eric is always fixing
                        the RegExp engine no matter which one he uses.

                        I'll be the first to tell you I am far from a RegExp expert, and
                        more like a trial and error beginner.

                        So, which do you use? Does anybody have one that works in all cases?

                        H=RegExp
                        ; ^!Find "<script>.*\n</script>" RSI
                        ; ^!Find "<script>\n+.*\n+.*\n+</script>" RSI
                        ; ^!Find "<script>\n+.*\n+</script>" RSI
                        ; ^!Find "<script>.*\n+.*<\/script>" RSI
                        ; ^!Find "<script>*\n.</script>" RSI
                        ; ^!Find "<script>.*\n.*</script>" RSI
                        ; ^!Find "<script>\n.*</script>" RSI
                        ; ^!Find "^<script>.*</script>" RSI
                        ; ^!Find "^\s+<script>.*<\/script>" RSI
                        ; ^!Find "<script>.*</script>" RSI
                        ; ^!Find "^<script>.*\n</script>" RSI
                        ; ^!Find "^<script>.*\n+</script>" RSI
                        ; ^!Find "^[^<script>].*[^</script>]" RSI
                        ; ^!Find "\<script\>\a*\<\/script\>" RSI
                        ; ^!Find "\<script\>.*\<\/script\>" RIS

                        Test text:

                        <script>dfhjsdfh
                        sfhjsfjsfj</script>

                        <script>
                        </script>

                        <script>
                        </script>

                        <script>
                        ghj dghjdg
                        </script>

                        <script>
                        dyjfj
                        dfyu
                        </script>

                        <script>dghfj dfhjj</script>

                        <script>dfg xgfh</script>

                        <script>
                        fgjk
                        fgjkgjk
                        gyuigot
                        </script>

                        Happy Clip'n!
                        Jody

                        http://www.notetab.net

                        Subscribe, UnSubscribe, Options
                        mailto:Ntb-Clips-Subscribe@yahoogroups.com
                        mailto:Ntb-Clips-UnSubscribe@yahoogroups.com
                        http://groups.yahoo.com/group/ntb-clips
                      • ...Tyrell...
                        Hi JodySounds like the right spot for it :), but the files section for ntb-clips is missing. same is true for the ntb-html group.... Tyrell...Sounds
                        Message 11 of 12 , Feb 4, 2002
                        • 0 Attachment
                          Hi Jody

                          Sounds like the right spot for it :), but the files section for ntb-clips
                          is missing.
                          same is true for the ntb-html group.

                          ... Tyrell...

                          >Sounds like a neat toy. ;) How about uploading it. If you do
                          >not have a server setup, you can upload to the file area for the
                          >HTML or Clips group at yahoo.


                          _________________________________________________________
                          Do You Yahoo!?
                          Get your free @... address at http://mail.yahoo.com
                        • Jody
                          Hi ...Tyrell..., ... Oops, members are now authorized to upload files. ... Happy Clip n! Jody http://www.notetab.net Subscribe, UnSubscribe, Options
                          Message 12 of 12 , Feb 4, 2002
                          • 0 Attachment
                            Hi ...Tyrell...,

                            >Sounds like the right spot for it :), but the files section for
                            >ntb-clips is missing.
                            >same is true for the ntb-html group.

                            Oops, members are now authorized to upload files.

                            >> Sounds like a neat toy. ;) How about uploading it. If you do
                            >> not have a server setup, you can upload to the file area for
                            >> the HTML or Clips group at yahoo.


                            Happy Clip'n!
                            Jody

                            http://www.notetab.net

                            Subscribe, UnSubscribe, Options
                            mailto:Ntb-Clips-Subscribe@yahoogroups.com
                            mailto:Ntb-Clips-UnSubscribe@yahoogroups.com
                            http://groups.yahoo.com/group/ntb-clips
                          Your message has been successfully submitted and would be delivered to recipients shortly.