Question Doesn't replace the < and > symbol as " "

msivasakthi

Member
Joined
Jan 12, 2009
Messages
6
Programming Experience
Beginner
Hi all,

I have tried to replace the < or > symbol with whit space as following, but it doesn't work well

dim key as string
key="<trip to goa>"

key=key.Replace("<", " ") ' also i have checked as key=key.Replace(chr(60)," ")
key=key.Replace(">", " ") ' also i have checked as key=key.Replace(chr(62)," ")


how can i replace those symbol as white space?
 
I copied your code and put it into my 2005, and it worked fine first time :D
 
if < symbol is occurred any where in string then it is replaced. but starting of the string then it doesn't replaced.

key="< trip" -> it is replaced correctly
key="<trip" -> it doesn't replaced correctly


what to do?
 
VB.NET:
        Dim key1 As String = "<trip to goa>".Replace("<", " ").Replace(">", " ")
        Console.WriteLine(key1)

        Dim key2 As String = "< trip to goa >".Replace("<", " ").Replace(">", " ")
        Console.WriteLine(key2)

Output (as expected):
VB.NET:
 trip to goa 
  trip to goa
 
I have designed text box in asp.net. That entered text value is manipulated by vb. if iam going to enter the text value of <trip to goa> then i need to change that value to trip to goa, for that i have used following code in vb


key=txt_keyword.Text
key=key.replace("<"," ").replace(">", " ")
session("searchkey")=key


that session key is send stored procedure of sql server 2005 for searching the entered from db by using the full index text....

this is my requirement... but when i entered the text value of <trip to goa> then it is passed the <trip to goa. so the full index is failed for searching...
 
Back
Top