For eg: -
public String DisplayinURLFormat(String sampleString,int urlIndex)
-
{
-
String tempString = "";
-
int beginIndex = sampleString.indexOf("http", urlIndex);
-
if(beginIndex!=-1)
-
{
-
int endIndex = sampleString.indexOf(' ', beginIndex);
-
if(endIndex==-1)
-
{
-
endIndex = sampleString.length();
-
}
-
String hyperString = sampleString.substring(beginIndex,endIndex);
-
tempString = sampleString.substring(0, beginIndex)+"<a href='" + hyperString + "'>"+hyperString+"</a>" + sampleString.substring( endIndex,sampleString.length());
-
urlIndex = endIndex + hyperString.length() + 13;
-
sampleString= tempString;
-
return DisplayinURLFormat(sampleString,urlIndex);
-
}
-
else
-
return sampleString;
-
}
-
Here i am making a string to URl if the string containd any http format.
like if i enter sampleStruing as "go to http://www.google.com" the http string shud appear in URl. but for this i need to use the escapeXml flag in HTML to ignore the conversion of < and > characters. Is there any other way to make the escaped in JAV code itself
8 15321
...
like if i enter sampleStruing as "go to http://www.google.com" the http string shud appear in URl. but for this i need to use the escapeXml flag in HTML to ignore the conversion of < and > characters. Is there any other way to make the escaped in JAV code itself
Err, I'm no XML/web man myself, so I don't know exactly what this kind of escape thing is you're talking about.
However, could you perhaps give a couple of example input-Strings and desired output-String? Perhaps then I can give you a hand.
OK, I have a string sampleString which contains a substring which is supposed to be printed in URL format, for that i have written the above function.
But anyhow i needed to use the escapeXml flag to set it to false in the jsp page not to convert the <a ref> tag to <a ref >.
The problem doing this is it may escape some of the valid tags which i dint want to escape. Here i want only <a ref></a> tags to be escaped
OK, I have a string sampleString which contains a substring which is supposed to be printed in URL format, for that i have written the above function.
But anyhow i needed to use the escapeXml flag to set it to false in the jsp page not to convert the <a ref> tag to <a ref >.
The problem doing this is it may escape some of the valid tags which i dint want to escape. Here i want only <a ref></a> tags to be escaped
Could you provide examples of in- and output?
For example: String "aaaaaaaabbbbbbbbbbbbbbssssssssssssssssssbbbb" comes in, and "aaaaaaaabbbXXXXXXXbbsssssXXXXXssssssssbbb" should come out.
"go to <a href='http://www.google.com'></a>" is input
"go to <a href='http://www.google.com'> </a>" is the out put
"go to <a href='http://www.google.com'></a>" is input
"go to <a href='http://www.google.com'> </a>" is the out put
Look at String's replaceAll(...) method.
Look at String's replaceAll(...) method.
Yeah, regexps! Gimme an 'r'! gimme an 'e'! gimme a 'g'! gimme an 'e'! ... erm,
sorry; it won't happen again.
kind regards,
Jos ;-)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Barry Olly |
last post by:
Hi,
I'm working on a mini content management system and need help with
dealing with special characters.
The input are taken from html form which are then stored into a
varchar column in...
|
by: Ewok |
last post by:
let me just say. it's not by choice but im dealing with a .net web app (top
down approach with VB and a MySQL database) sigh.....
Anyhow, I've just about got all the kinks worked out but I am...
|
by: Carl Mercier |
last post by:
Hi,
Is it possible to use special characters like \n or \t in a VB.NET
string, just like in C#? My guess is NO, but maybe there's something I
don't know.
If it's not possible, does anybody...
|
by: david.lindsay.green |
last post by:
Hello all, I am quite new a web scripting and making web pages in
general and I have stumbled across a problem I have as yet been unable
to solve. I am trying to take the contents of a textarea box...
|
by: SeanGerman |
last post by:
Howdy,
Is there a way to explicitly escape special characters (particularly &
(&) and ' (')) when writing a data set with the WriteXml
method?
I know this is supposed to happen...
|
by: Doc |
last post by:
Hello!
I'm experiencing a little problem counting the number of characters in
a textarea on a html page.
This is the content type of my HTML document
content="text/html; charset=iso-8859-1"
...
|
by: Wim Cossement |
last post by:
Hello,
I was wondering if there are a few good pages and/or examples on how to
process form data correctly for putting it in a MySQL DB.
Since I'm not used to using PHP a lot, I already found...
|
by: forest demon |
last post by:
i need to escape characters, such as ( % and/or _ and/or [ ),
since i have database entries that have such characters in them.
the following piece works fine in an SQL statement (c#), but...
|
by: KevinADC |
last post by:
Purpose
The purpose of this article is to discuss the difference between characters inside a character class and outside a character class and some special characters inside a character class....
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
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...
|
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...
| |