For eg:
[code=java]
public String DisplayinURLFor mat(String sampleString,in t urlIndex)
{
String tempString = "";
int beginIndex = sampleString.in dexOf("http", urlIndex);
if(beginIndex!=-1)
{
int endIndex = sampleString.in dexOf(' ', beginIndex);
if(endIndex==-1)
{
endIndex = sampleString.le ngth();
}
String hyperString = sampleString.su bstring(beginIn dex,endIndex);
tempString = sampleString.su bstring(0, beginIndex)+"<a href='" + hyperString + "'>"+hyperStrin g+"</a>" + sampleString.su bstring( endIndex,sample String.length() );
urlIndex = endIndex + hyperString.len gth() + 13;
sampleString= tempString;
return DisplayinURLFor mat(sampleStrin g,urlIndex);
}
else
return sampleString;
}
[/code]
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
[code=java]
public String DisplayinURLFor mat(String sampleString,in t urlIndex)
{
String tempString = "";
int beginIndex = sampleString.in dexOf("http", urlIndex);
if(beginIndex!=-1)
{
int endIndex = sampleString.in dexOf(' ', beginIndex);
if(endIndex==-1)
{
endIndex = sampleString.le ngth();
}
String hyperString = sampleString.su bstring(beginIn dex,endIndex);
tempString = sampleString.su bstring(0, beginIndex)+"<a href='" + hyperString + "'>"+hyperStrin g+"</a>" + sampleString.su bstring( endIndex,sample String.length() );
urlIndex = endIndex + hyperString.len gth() + 13;
sampleString= tempString;
return DisplayinURLFor mat(sampleStrin g,urlIndex);
}
else
return sampleString;
}
[/code]
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
Comment