Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   A program to replace all JS comments with JSP comments in jsp files (http://www.velocityreviews.com/forums/t925086-a-program-to-replace-all-js-comments-with-jsp-comments-in-jsp-files.html)

tungchau81@yahoo.com 06-02-2006 06:11 AM

A program to replace all JS comments with JSP comments in jsp files
 
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


Erwin Moller 06-02-2006 08:11 AM

Re: A program to replace all JS comments with JSP comments in jsp files
 
tungchau81@yahoo.com 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

Hal Rosser 06-02-2006 07:46 PM

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

<tungchau81@yahoo.com> wrote in message
news:1149228660.375389.197930@f6g2000cwb.googlegro ups.com...
> 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



Ian Collins 06-02-2006 09:48 PM

Re: A program to replace all JS comments with JSP comments in jspfiles
 
tungchau81@yahoo.com 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.

Dr John Stockton 06-03-2006 02:00 PM

Re: A program to replace all JS comments with JSP comments in jsp files
 
JRS: In article <OA0gg.68663$MM6.49512@bignews3.bellsouth.net>, dated
Fri, 2 Jun 2006 15:46:56 remote, seen in news:comp.lang.javascript, Hal
Rosser <hrosser@gmail.com> 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/>


All times are GMT. The time now is 12:33 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.