0

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:

testing-this-on-the-test-forum-please-remove-if-possible-test-test-abc

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.

Community
  • 1
  • 1
Marife
  • 1

1 Answers1

0

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)
        newstring+=character;
    else
        newstring+="-";

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

That should be a start for you.

Schroedingers Cat
  • 3,043
  • 1
  • 12
  • 33