Normalizes a string by replacing non-word characters with a space character.
normalize('Hello_World!123')// => { ok: true, value: 'Hello World 123' }// => Hello World 123normalize('This is a sample string.')// => { ok: true, value: 'This is a sample string' } Copy
normalize('Hello_World!123')// => { ok: true, value: 'Hello World 123' }// => Hello World 123normalize('This is a sample string.')// => { ok: true, value: 'This is a sample string' }
Returns the default if there is an error:
normalize(10).unwrapOr('')// => '' Copy
normalize(10).unwrapOr('')// => ''
Handling non-string input:
normalize(42)// => { ok: false, error: Error('[strings.normalize] Expected string value as input') } Copy
normalize(42)// => { ok: false, error: Error('[strings.normalize] Expected string value as input') }
The string normalize.
A Result object with either the normalized string on success, or an Error object if the provided input is not a string.
Result
Error
Generated using TypeDoc v0.24.7
Normalizes a string by replacing non-word characters with a space character.
Example
Example
Returns the default if there is an error:
Example
Handling non-string input: