473,406 Members | 2,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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

Jun 2 '06 #1
4 2162
tu********@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
Jun 2 '06 #2

<tu********@yahoo.com> wrote in message
news:11**********************@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
Jun 2 '06 #3
tu********@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.
Jun 2 '06 #4
JRS: In article <OA*******************@bignews3.bellsouth.net>, dated
Fri, 2 Jun 2006 15:46:56 remote, seen in news:comp.lang.javascript, Hal
Rosser <hr*****@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/>
Jun 3 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mike | last post by:
I am sure that I am making a simple boneheaded mistake and I would appreciate your help in spotting in. I have just installed apache_2.0.53-win32-x86-no_ssl.exe php-5.0.3-Win32.zip...
11
by: James Hu | last post by:
This program is long. I don't really want to bore everyone with the details, but it handles wierd cases like: /\ * this is a comment *\ / #define FOO ??/* this is not a comment */ char...
4
by: Hardy Wang | last post by:
Hi: I have a XML like <?xml version="1.0" ?> <object> <comments>www.site.com/page.aspx?param1=value1&param2=value2</comments> </object> Since "&" is invalid in XML, I need to replace all "&"...
4
by: KenFehling | last post by:
Hello. I am wondering if there exists a piece of software that takes multiple .js files that are nicely indented and commented and create one big tightly packed .js file. I'm hoping the one file...
22
by: Mike Polinske | last post by:
I am new to the C programming language but have been programming in Cobol for over 10 years. When I compile the following code, it compiles clean but I get an application error both under Windows...
20
by: Francine.Neary | last post by:
I am learning C, having fun with strings & pointers at the moment! The following program is my solution to an exercise to take an input, strip the first word, and output the rest. It works fine...
4
by: neptundancer | last post by:
Hi, to extend my skills, I am learning python. I have written small program which computes math expression like "1+2*sin(y^10)/cos(x*y)" and similar, so far only + - * / ^ sin con tan sqrt are...
3
by: lex __ | last post by:
I'm tryin to use regexp to replace multi-line c-style comments (like /* this /n */ ) with /n (newlines). I tried someting like re.sub('/\*(.*)/\*' , '/n' , file) but it doesn't work for...
2
by: WP | last post by:
Hello, below is my very first python program. I have some questions regarding it and would like comments in general. I won't be able to get my hands on a good python book until tomorrow at the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.