Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /article/1/Some_Article_Title_Here
- /article/1/Section/5/Section_Title_Here
- /section/19023/Section_Title_here ( == above link )
- http://www.example.com/x/category-name/subcat-name/article-name/348254863
- Route r = new Route("{country}/{lang}/Article/{id}/{title}/", new NFRouteHandler("OneArticle"));
- Route r2 = new Route("{country}/{lang}/Section/{id}-{subid}/{title}/", new NFRouteHandler("ArticlesInSubcategory"));
- Route r3 = new Route("{country}/{lang}/Section/{id}/{title}/", new NFRouteHandler("ArticlesByCategory"));
- private static string anglicized(this string urlpart) {
- string before = "àÀâÂäÄáÁéÉèÈêÊëËìÌîÎïÏòÒôÔöÖùÙûÛüÜçÇ’ñ";
- string after = "aAaAaAaAeEeEeEeEiIiIiIoOoOoOuUuUuUcC'n";
- string cleaned = urlpart;
- for (int i = 0; i < avantConversion.Length; i++ ) {
- cleaned = Regex.Replace(urlpart, before[i].ToString(), after[i].ToString());
- }
- return cleaned;
- // Here's some for Spanish : ÁÉÍÑÓÚÜ¡¿áéíñóúü"
- }
- string articleTitle = "My Article about café and the letters àâäá";
- string cleaned = articleTitle.anglicized();
- // replace spaces with dashes
- cleaned = Regex.Replace( cleaned, "[^A-Za-z0-9- ]", "");
- // strip all illegal characters like punctuation
- cleaned = Regex.Replace( cleaned, " +", "-").ToLower();
- // returns "my-article-about-cafe-and-the-letters-aaaa"
Add Comment
Please, Sign In to add comment