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

T

tungchau81

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
 
E

Erwin Moller

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
 
H

Hal Rosser

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
 
I

Ian Collins

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
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated
Fri, 2 Jun 2006 15:46:56 remote, seen in Hal
Rosser said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,830
Latest member
ZADIva7383

Latest Threads

Top