A program to replace all JS comments with JSP comments in jsp files

Discussion in 'Javascript' started by tungchau81@yahoo.com, Jun 2, 2006.

  1. Guest

    Hi,
    I have a lot of JSP files that serve as pure JavaScript code. I need to
    convert all JavaScript comments inside these JSP files to JSP comments
    which use <%-- // --%> tags. Instead of doing it manually, I would
    like to write a script/program that can detect the JS declarative
    comment structure and replace it with the equivalent JSP comment.
    However, I do not know how to start writing such kind of
    script/program. I would appreciate alot if you can suggest me some
    tool/program, Linux shell command or programming language (Perl,
    JavaScript, ...) that I can use. Is there any available program out
    there that is doing this task ?

    Thanks in advance,
    Tung Chau
    , Jun 2, 2006
    #1
    1. Advertising

  2. Erwin Moller Guest

    wrote:

    > Hi,
    > I have a lot of JSP files that serve as pure JavaScript code. I need to
    > convert all JavaScript comments inside these JSP files to JSP comments
    > which use <%-- // --%> tags. Instead of doing it manually, I would
    > like to write a script/program that can detect the JS declarative
    > comment structure and replace it with the equivalent JSP comment.
    > However, I do not know how to start writing such kind of
    > script/program. I would appreciate alot if you can suggest me some
    > tool/program, Linux shell command or programming language (Perl,
    > JavaScript, ...) that I can use. Is there any available program out
    > there that is doing this task ?
    >
    > Thanks in advance,
    > Tung Chau


    Hi Tung,

    Well, what you are asking for is a straightforward search-replace alghoritm,
    right?
    Such tasks are easy with scriptinglanguages like PHP or Perl.
    Even VB-script should be able to do it. ;-)

    My Perl suck these days, so if you can go PHP, have a look at:
    http://nl2.php.net/manual/en/function.str-replace.php
    and fopen() for opening.

    try to make a program that opens all files, replaces your commentstags, and
    then safes the file.

    Regards,
    Erwin Moller
    Erwin Moller, Jun 2, 2006
    #2
    1. Advertising

  3. Hal Rosser Guest

    <> wrote in message
    news:...
    > Hi,
    > I have a lot of JSP files that serve as pure JavaScript code. I need to
    > convert all JavaScript comments inside these JSP files to JSP comments
    > which use <%-- // --%> tags. Instead of doing it manually, I would
    > like to write a script/program that can detect the JS declarative
    > comment structure and replace it with the equivalent JSP comment.
    > However, I do not know how to start writing such kind of
    > script/program. I would appreciate alot if you can suggest me some
    > tool/program, Linux shell command or programming language (Perl,
    > JavaScript, ...) that I can use. Is there any available program out
    > there that is doing this task ?
    >
    > Thanks in advance,
    > Tung Chau
    >


    That wheel has already been invented.
    You can google to find a shareware to search/replace through an entire
    directory.
    Its been several years since I used one, so the name of the one I used has
    departed the memory banks.
    But look at it as a find-replace task, heck, even MS Word can do that for a
    file at a time.
    HTH Hal
    Hal Rosser, Jun 2, 2006
    #3
  4. Ian Collins Guest

    Re: A program to replace all JS comments with JSP comments in jspfiles

    wrote:
    > Hi,
    > I have a lot of JSP files that serve as pure JavaScript code. I need to
    > convert all JavaScript comments inside these JSP files to JSP comments
    > which use <%-- // --%> tags. Instead of doing it manually, I would
    > like to write a script/program that can detect the JS declarative
    > comment structure and replace it with the equivalent JSP comment.
    > However, I do not know how to start writing such kind of
    > script/program. I would appreciate alot if you can suggest me some
    > tool/program, Linux shell command or programming language (Perl,
    > JavaScript, ...) that I can use. Is there any available program out
    > there that is doing this task ?
    >

    man find
    man sed

    --
    Ian Collins.
    Ian Collins, Jun 2, 2006
    #4
  5. JRS: In article <OA0gg.68663$>, dated
    Fri, 2 Jun 2006 15:46:56 remote, seen in news:comp.lang.javascript, Hal
    Rosser <> posted :
    >
    >That wheel has already been invented.
    >You can google to find a shareware to search/replace through an entire
    >directory.


    Why go to that expense? See in sig.

    --
    © John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
    Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
    I find MiniTrue useful for viewing/searching/altering files, at a DOS prompt;
    free, DOS/Win/UNIX, <URL:http://www.idiotsdelight.net/minitrue/>
    Dr John Stockton, Jun 3, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    1,095
  2. Xah Lee
    Replies:
    1
    Views:
    1,356
    YYusenet
    Jan 31, 2005
  3. Vellingiri Arul
    Replies:
    24
    Views:
    397
    On Web
    Sep 22, 2007
  4. Xah Lee
    Replies:
    0
    Views:
    329
    Xah Lee
    Jan 31, 2005
  5. Replies:
    5
    Views:
    465
    Wolf Behrenhoff
    May 15, 2009
Loading...

Share This Page