A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
| function slugify(text) { | |
| return text.toString().toLowerCase().trim() | |
| .normalize('NFD') // separate accent from letter | |
| .replace(/[\u0300-\u036f]/g, '') // remove all separated accents | |
| .replace(/\s+/g, '-') // replace spaces with - | |
| .replace(/&/g, '-and-') // replace & with 'and' | |
| .replace(/[^\w\-]+/g, '') // remove all non-word chars | |
| .replace(/\-\-+/g, '-') // replace multiple '-' with single '-' | |
| } |