TAGS :Viewed: 5 - Published at: a few seconds ago

[ How can I change a string to make it URL friendly? ]

Possible Duplicate:
URL Slugify alrogithm in C#?

I would like to convert a string like this:

Testing this on-the-test-forum (please/remove) if possible. test: test, "abc"

To a string like this:


Does anyone have any ideas on the simplest type of function that I could use for this. What I am looking for is something very simple as I need to use this function later within LINQ.

Answer 1

Your easiest approach would seem to be identifying the characters that you do want in the returned string and code it based on these. So, in pseudocode:

newstring = "";

foreach(character in newstring.tolower)
    if(character in allowedcharacters)

return newstring.replace("--","-");

That should be a start for you.