• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need help on Regular Expression

 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have to replace all my HTML comment from my jsps with hidden comment that is

<!--my comment --> will be replaced to <%--my comment --%>

I want a regular expression through I can search the HTML comment and replace that with <%-- --%>
The comment text should not alter .

Can anybody please help .
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you on a *nix type system? If so I would create a script that looks something like this:



I didn't test this out or anything...just a quick and dirty example.

Good Luck!
 
Monoj Roy
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot for your reply but I am working on XP peofessional .. with RSA .
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Monoj,
RSA is built on Eclipse so you can use the same approach you'd take in Eclipse. Why use a regular expression though?

It seems easier to replace "<!--" with "<%--" as a plain text search and replace. And "-->" with "..%>" Trying to do it in one step just adds complexity.
 
Monoj Roy
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks .The reason I wast to go for a regular expression or batch file or any programatic approach because I have
to do this action for over 700 files . To do it manually it can be error prone and will take much time
 
Rancher
Posts: 377
Android Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,
Since I am always looking for some little task to keep me entertained, I'd just create a small java program to do it!
All you really need is the File API, some recursion to traverse the directories, look for JSPs and use the "string".replace() method.

Better than doing it manually anyway!

Sean
 
Monoj Roy
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Following code is working file for one file I passed hard coded . I want all the jsps that are in a directory and sub directory .How to get all file from a directory ?
Can any body help me to update the code.
 
Sean Clark
Rancher
Posts: 377
Android Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

Have a look at the File api.
This is the only class you will need to recursively go through your folders and files.

Sean
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic