From 433d9fdec8118ec4bf5cb5590192c8faf659477a Mon Sep 17 00:00:00 2001 From: Steven Thompson Date: Wed, 6 May 2020 11:22:13 +0100 Subject: [PATCH] Add example for strict mode --- README.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6b0e87d..9e67cc4 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,27 @@ slugify('some string', { }) ``` -For example, to remove `*+~.()'"!:@` from the result slug, you can use `slugify('..', {remove: /[*+~.()'"!:@]/g})`. +### Examples + +#### Remove special characters + +Remove `$*_+~.()'"!\-:@`. + +```js +let slug = 'foo *+~.() bar \'"!:@ baz' +slugify(slug, {remove: /[$*_+~.()'"!\-:@]/g}) +// foo-bar-baz +``` + +#### Strict mode + +Remove any character that doesn't match `[a-zA-Z0-9-]`, except the replacement. + +```js +let slug = 'foo_bar. -baz!' +slugify(slug, {strict: true}) +// foobar-baz +``` ## Extend