12345678910111213141516171819202122232425262728 |
- const cssRegex = /^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/
- export default function stripUnit(value: string | number): string | number {
- if (typeof value !== 'string') return value
- const matchedValue = value.match(cssRegex)
- return matchedValue ? parseFloat(value) : value
- }
|