basic string functions
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   sat_ya
Posted On:   Monday, October 3, 2005 04:37 AM

hi all.
im getting the data from db throu jsp and generating an xml file..
the prob is when the name field contains ampersand(&) symbol, its generating an error..
so i want to replace & with &
how to do it...
and i want to extract a part of the string ...
how to do it..
any help in this regard, greatly appreciated...
tia
satya

Re: basic string functions

Posted By:   Stephen_Ostermiller  
Posted On:   Monday, October 3, 2005 01:31 PM

I have a function that does this in my StringHelper class. Also a method that does the reverse. The methods are:

  • static String escapeHTML(String s)

  • static String unescapeHTML(String s)



http://ostermiller.org/utils/StringHelper.html

Re: basic string functions

Posted By:   Joost_Schouten  
Posted On:   Monday, October 3, 2005 08:52 AM

This will replace it.

myString = myString.replaceAll("&", "&");

It might however cause some regulair expression issues as the & symbol plays a role in that aswell I believe. Give it a go first and if it fails read up on it. The String API will show you all possible methods you can perform on a string. It also talks about regulair expressions.


Cheers,

Joost

About | Sitemap | Contact