Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add option to split on digit substrings #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = (str, options) => {
if (typeof str !== 'string') throw new TypeError('expected a string');
return str.trim()
.replace(/([a-z])([A-Z])/g, '$1-$2')
.replace(/(\d+)/g, m => options && options.splitOnDigits ? `-${m}-` : m)
.replace(/\W/g, m => /[À-ž]/.test(m) ? m : '-')
.replace(/^-+|-+$/g, '')
.replace(/-{2,}/g, m => options && options.condense ? '-' : m)
Expand Down