DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
JavaScript Function To Generate URLs Without Any Rubbish
// We couldn't find any free function available, for this reason our Sergey built an collection of amazing JS //function for Orchid box CMS. We have decided to release it to the world so no other developer should //struggle //as we did. eg. This, is my post n.1? = this_is_my_post_n_1
//Have you ever wanted to generate perfect URL from blog post or any page title?
//We couldn't find any free function available, for this reason our Sergey built an collection of amazing JS //function for Orchid box CMS. We have decided to release it to the world so no other developer should //struggle as we did.
//URL stripper features:
//- Strip of any non alphanumeric characters
//- Space converted to _
//- Not more than one _ between alphanumeric characters
//- JS function can be invoked on focus, hence very fast
//The function : GenerateUrl would transform :
//source: this is my title
//result: this_is_my_title
//Source: This is my n.1 post, really ? Should I have written more , or less ?
//Result: This_is_my_n_1_post_really_Should_I_have_written_more_or_less
//Source: rubbish characters : &^%&^%&%*^(**&^%"£%"££^%$&^%^& (I am not rubbish)
//Result: rubbish_characters_I_am_not_rubbish
http://digg.com/software/JavaScript_function_to_generate_URLs_without_any_rubbish





