相关疑难解决方法(0)

Creating Slugs from Titles?

I have everything in place to create slugs from titles, but there is one issue. My RegEx replaces spaces with hyphens. But when a user types "Hi     there" (multiple spaces) the slug ends up as "Hi-----there". When really it should be "Hi-there".

Should I create the regular expression so that it only replaces a space when there is a character either side?

Or is there an easier way to do this?

javascript regex slug

6
推荐指数
3
解决办法
2102
查看次数

标签 统计

javascript ×1

regex ×1

slug ×1