You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
475 B

import { escapeRegExp } from './escapeRegExp';
type Options = {
decimalSeparator?: string;
groupSeparator?: string;
};
export const getSuffix = (
value: string,
{ groupSeparator = ',', decimalSeparator = '.' }: Options
): string | undefined => {
const suffixReg = new RegExp(
`\\d([^${escapeRegExp(groupSeparator)}${escapeRegExp(decimalSeparator)}0-9]+)`
);
const suffixMatch = value.match(suffixReg);
return suffixMatch ? suffixMatch[1] : undefined;
};