• Post Reply Bookmark Topic Watch Topic
  • New Topic

serach and replace

 
Didier McGillis
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Generically how could I perform a search and replace on a link or text
piece that came from a
database.
Here is an example. I need to tag links with special identifiers on
some JSP pages. The links
are sent via the database to a template, so you cannot parse the tags
the normal way or use
functions since the page is already been parsed. Someone said to use a
search and replace.
What is the best way to do that.
 
greg philpott
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
put what needs searhing into a javaranch string:
com.javaranch.common.Str str = new Str(yourString);
then call replace(String s1, String s2) on it.
be careful though, you might want to take a look at the new regex package (new to JDK1.4) to use strict replacement patterns
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!