front/src/utils/formatter.ts

16 lines
476 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* 录入英文,数字 ,+ _ - / . , : ; & % * # {} 【】 [] () () */
export function inputEnNum(v: string, isUpper = false) {
const str = v.replace(
/[^a-zA-Z0-9\+\_\-\.\,\:\;\&\%\*\#\{\}\【\】\[\]\(\)()]/g,
''
);
return isUpper ? str.toUpperCase() : str;
}
/* 录入英文 不带字符 */
export function inputEnglishSpace(v: string, isUpper = false) {
const str = v.replace(/[^a-zA-Z]/g, '');
return isUpper ? str.toUpperCase() : str;
}