Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
VB
Hi

i get value as

Situated+on+the+amazing+artificial+island+of+Palm+Jumeirah%2C+the+hotel+is+only+a+15-minute+drive+from+the+Emirates+Shopping+Centre+and+25+minutes+from+the+city+centre.+This+truly+spectacular+development+features+two+hotel+towers+linked+by+an+arch+and+is+Dubai%27s+first+truly+integrated+resort.+The+hotel+lobby+provides+a+24-hour+reception%2C+as+well+as+numerous+bars+and+restaurants.+Guests+can+also+take+advantage+of+the+hotel%27s+room+and+laundry+services.

PO+BOX+211222%2C+CRESCENT+ROAD%2C+THE+PALM%2C+DUBAI

how to make it readable (by removing all special characters)  in asp.net  and display in html page
Posted

Hi
Try like this..


C#
static void Main(string[] args)
        {

            string input = " Situated+on+the+amazing+artificial+island+of+Palm+Jumeirah%2C+the+hotel+is+only+a+15-minute+drive+from+the+Emirates+Shopping+Centre+and+25+minutes+from+the+city+centre.+This+truly+spectacular+development+features+two+hotel+towers+linked+by+an+arch+and+is+Dubai%27s+first+truly+integrated+resort.+The+hotel+lobby+provides+a+24-hour+reception%2C+as+well+as+numerous+bars+and+restaurants.+Guests+can+also+take+advantage+of+the+hotel%27s+room+and+laundry+services. " +
   "PO+BOX+211222%2C+CRESCENT+ROAD%2C+THE+PALM%2C+DUBAI";

            string[] tokensToBeRemoved = {"+","%","-" };

             tokensToBeRemoved.ToList().ForEach(k => input = input.Replace(k, " "));

             var output = input;


        }
 
Share this answer
 
Use Following Expression...

C#
string str;
str= Regex.Replace(str, "+", " ");
 
Share this answer
 
Comments
maulikshah1990 4-Dec-13 0:38am    
if i use the above code , i get
System.ArgumentException: parsing "+" - Quantifier {x,y} following nothing.
maulikshah1990 4-Dec-13 0:42am    
Hi

i have a string as

Double+Deluxe+%282+Adults%29++Bed+And+Breakfast+Included+%26lt%3Bfont+color%3D%26quot%3Bred%26quot%3B%26gt%3B%26lt%3B%2Ffont%26gt%3B



i did

RoomDescription="Double+Deluxe+%282+Adults%29++Bed+And+Breakfast+Included+%26lt%3Bfont+color%3D%26quot%3Bred%26quot%3B%26gt%3B%26lt%3B%2Ffont%26gt%3B";

String DataString = Uri.UnescapeDataString(RoomDescription);
string replacestr = DataString.Replace("+", " ");

string formattedValue = Regex.Replace(replacestr, @"[^\w\d]", " ");

and in

formattedValue i get value as "Double Deluxe 2 Adults Bed And Breakfast Included lt font color quot red quot gt lt font gt";

now how to remove all unwanted i.e. lt font color quot red quot gt lt font gt

or what is this " lt font color quot red quot gt lt font gt";
this

and read this


it may use.
 
Share this answer
 
v2
Comments
maulikshah1990 3-Dec-13 23:38pm    
Hi..thanks..but i get the above from xml into asp.net code..then how to make it properly readable
You can try Regex or even simply using a stringbuilder class.

http://stackoverflow.com/questions/1120198/most-efficient-way-to-remove-special-characters-from-string[^]

For readability you can replace special characters with space as below

http://www.aspdotnet-suresh.com/2013/09/csharp-replace-all-special-characters-with-space-in-string.html[^]

Hope this helps
 
Share this answer
 
v2
Comments
maulikshah1990 4-Dec-13 0:20am    
Also , i have other string as
Double+Deluxe+%282+Adults%29++Bed+And+Breakfast+Included+%26lt%3Bfont+color%3D%26quot%3Bred%26quot%3B%26gt%3B%26lt%3B%2Ffont%26gt%3B+

how to make this readable

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900