javascript - Jquery, Convert Title to Slug - Stack Overflow

I have a PHP script that does the following: It takes a string, for example, "This is a Great Blog

I have a PHP script that does the following: It takes a string, for example, "This is a Great Blog Post, #1!", and returns the following string, "this-is-a-great-blog-post-1".

I'm not exactly a Jquery expert, that's why I'm asking this question. Does someone know of a Jquery (or Javascript, for that matter) script that will do the same thing as my script? Thanks in advance.

Will

I have a PHP script that does the following: It takes a string, for example, "This is a Great Blog Post, #1!", and returns the following string, "this-is-a-great-blog-post-1".

I'm not exactly a Jquery expert, that's why I'm asking this question. Does someone know of a Jquery (or Javascript, for that matter) script that will do the same thing as my script? Thanks in advance.

Will

Share Improve this question asked Feb 18, 2010 at 21:24 willbeelerwillbeeler 6891 gold badge13 silver badges26 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 15

Or you could write your own version in about 45 seconds:

var str = "This is a Great Blog Post, #1!";
str = str.replace(/[^a-zA-Z0-9\s]/g,"");
str = str.toLowerCase();
str = str.replace(/\s/g,'-');
document.write(str);

// outputs "this-is-a-great-blog-post-1"

Theres a plugin for that! :)

Try this one slugit-jquery, it has decent multilanguage support.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1739295204a4121038.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信