@t7/utils
Version:
Utility methods for T7 components.
33 lines (23 loc) • 427 B
JavaScript
// Dependencies.
import { exists } from './'
/*
Helper to format alphanumeric strings.
BEFORE:
- "A!@#$%^&*()_+9"
AFTER:
- "A9"
*/
const formatAlphanumeric = (value) => {
// Early exit.
if (!exists(value)) {
return ''
}
// To string.
value = String(value)
// Format.
value = value.replace(/[^A-Z0-9]/gi, '')
// Expose string.
return value
}
// Export.
export default formatAlphanumeric