declare namespace StringUtil { /** * 判断字符串是否不为空 * @param {String} input 输入字符串,如'我是测试的字符串' * @example * isNotEmpty('我是测试的字符串'); => true * isNotEmpty(''); => false */ const isNotEmpty: (input: string) => boolean; /** * 将字符串去除空格 * @param {string} input 输入字符串,如'我是测 试的字符串' * @returns {string} 去除空格后的字符串 * @example * trim(' 测试字符串 '); => 测试字符串 * trim('我是测 试的字符串'); => 我是测试的字符串 */ const trim: (input: string) => string; /** * 判断字符串是否以某个字符串开头 * @param {string} input 输入字符串,如' abcdefg' * @param {string} prefix 输入字符串,如'ab' * @example * startsWith('abcdefg','ab'); => true * startsWith('abcdefg','bc'); => false * startsWith('abcdefg','a'); => true */ const startsWith: (input: string, prefix: string) => boolean; /** * 判断字符串是否以某个字符串结束 * @param {String} input 输入字符串,如' abcdefg ' * @param {string} suffix 输入字符串,如'fg' * @examplec * endsWith('abcdefg', 'fg'); => true * endsWith('abcdefg', 'ef'); => false * endsWith('abcdefg', 'g'); => true */ const endsWith: (input: string, suffix: string) => boolean; /** * 判断字符串是否包含某个字符串 * @param {String} input 输入字符串,如'abcdefg' * @param {string} searchSeq 输入字符串,如'abc' * @example * contains('abcdefg', 'abc'); => true * contains('abcdefg', 'gh'); => false * contains('abcdefg', 'a'); => true */ const contains: (input: string, searchSeq: string) => boolean; /** * 忽略大小写判断两个字符串是否相等 * @param {String} input1 输入字符串,如'equalsIgnoreCasE', * @param {String} input2 输入字符串,如'equalsIgnoreCase' * @example * equalsIgnoreCase('equalsIgnoreCasE', 'equalsIgnoreCase'); => true * equalsIgnoreCase('equals ', 'equalsIgnoreCase'); => false */ const equalsIgnoreCase: (input1: string, input2: string) => boolean; /** * 判断字符串是否含有空格 * @param {String} input 输入字符串,如'我是 测试 的 字符串' * @example * containsWhitespace('我是 测试 的 字符串 '); => true * containsWhitespace('我是测试的字符串'); => false * containsWhitespace(' 我是测试的字符串 '); => true */ const containsWhitespace: (input: string) => boolean; /** * 按指定数量生成给定字符串字符 * @param {string|number} ch 输入字符串,如'我是测试的字符串', 或 输入数字如 220022 * @param {number} repeatTimes 输入数字,如 '6' * @returns {string} 指定数量的给定字符串 * @example * repeat('AB ',6); => 'AB AB AB AB AB AB ' * repeat('C D',3); => 'C DC DC D' * repeat('20', 3); => '202020' */ const repeat: (ch: string | number, repeatTimes: number) => string; /** * 去除字符串中的空格 * @param {string} input 输入字符串,如'我是 测试 的 字符串 ' * @returns {string} 去除空格后的字符串 * @example * deleteWhitespace('我是 测试 的 字符串 '); => '我是测试的字符串' * deleteWhitespace(''); => '' */ const deleteWhitespace: (input: string) => string; /** * 将给定字符串进行右侧填充 * @param {string|number} input 输入字符串 * @param {number} size 输入数量 * @param {string|number } padStr 输入填充字符 * @example * rightPad(2222, 1, 33); => '222233' * rightPad('我是测试的字符串', 2, '--'); => '我是测试的字符串----' */ const rightPad: (input: string | number, size: number, padStr: number | string) => string; /** * 将给定字符进行左侧填充 * @param {string|number} input 输入字符串 * @param {number} size 输入数量 * @param {string|number} padStr 输入填充字符 * @returns {string} 左侧填充后的字符串 * @example * leftPad('我是测试的字符串', 2, '--'); => '----我是测试的字符串' * leftPad(2222, 2, 3); => '332222' */ const leftPad: (input: string | number, size: number, padStr: number | string) => string; /** * 将字符串首字母转大写 * @param {string} input 输入字符串 * @example * capitalize('admin'); => 'Admin' * capitalize('capitalize'); => 'Capitalize' */ const capitalize: (input: string) => string; /** * 将字符串首字母转小写 * @param {string} input 输入字符串 * @example * unCapitalize('Capitalize'); => 'capitalize' * unCapitalize('SetTimeout'); => 'setTimeout' */ const unCapitalize: (input: string) => string; /** * 将字符串中的字母大写转小写,小写转大写 * @param {string} input 输入字符串 * @example * swapCase('aBcde'); => 'AbCDE' * swapCase('ABCDe'); => 'abcdE' */ const swapCase: (input: string) => string; /** * 统计含有的子字符串的个数 * @param {string} input 输入字符串 * @param {string} sub 输入子字符串 * @example * countMatches('dabddadb', 'da'); => 2 * countMatches('abcdeabcdeabcde','ab'); => 3 */ const countMatches: (input: string, sub: string) => number; /** * 判断字符串是否为字母 * @param {string} input 输入字符串 * @example * isAlpha('abce测试'); => false * isAlpha('abcdeabcdeabcde'); => true */ const isAlpha: (input: string) => boolean; /** * 判断字符串是否为字母、空格 * @param {string} input 输入字符串 * @example * isAlphaSpace(' abc 测试 '); => false * isAlphaSpace('abcd eabc deab cde'); => true */ const isAlphaSpace: (input: string) => boolean; /** * 判断字符串是否为字母、数字 * @param {string} input 输入字符串 * @example * isAlphanumeric('abcd串abcd'); => false * isAlphanumeric('22abcdeabcdeabcde22'); => true */ const isAlphanumeric: (input: string) => boolean; /** * 判断字符串是否为字母、数字和空格 * @param {string} input 输入字符串 * @example * isAlphanumericSpace('我是测试的 222字符串'); => false * isAlphanumericSpace('22abcde abcde abcde 22'); => true */ const isAlphanumericSpace: (input: string) => boolean; /** * 判断字符串是否为数字 * @param {string} input 输入数字 * @example * isNumeric('我是测试的 字符串'); => false * isNumeric(220022); => true */ const isNumeric: (input: string) => boolean; /** * 判断字符串是否为小数 * @param {string} input 输入数字 * @example * isDecimal('220022'); => false * isDecimal(22.0022); => true */ const isDecimal: (input: string) => boolean; /** * 判断字符串是否为负小数 * @param {number} input 输入数字 * @example * isNegativeDecimal('22.0022'); => false * isNegativeDecimal('-22.0022'); => true */ const isNegativeDecimal: (input: string) => boolean; /** * 判断字符串是否为正小数 * @param {string} input 输入数字 * @example * isPositiveDecimal('22.0022'); => true * isPositiveDecimal('-22.0022'); => false */ const isPositiveDecimal: (input: string) => boolean; /** * 判断字符串是否为整数 * @param {string} input 输入数字 * @example * isInteger('-220022'); => true * isInteger('22.0022'); => false */ const isInteger: (input: string) => boolean; /** * 判断字符串是否为正整数 * @param {string} input 输入数字 * @example * isPositiveInteger('220022'); => true * isPositiveInteger('-22.22'); => false */ const isPositiveInteger: (input: string) => boolean; /** * 判断字符串是否为负整数 * @param {string} input 输入数字 * @example * isNegativeInteger('-220022'); => true * isNegativeInteger('22.22'); => false */ const isNegativeInteger: (input: string) => boolean; /** * 判断字符串是否为数字、空格 * @param {string} input 输入字符串 * @example * isNumericSpace('2 2 0 0 2 2'); => true * isNumericSpace('2222aa'); => false */ const isNumericSpace: (input: string) => boolean; /** * 判断字符串是否为空格 * @param {string} input 输入字符串 * @example * isWhitespace(' '); => true * isWhitespace('22.22'); => false */ const isWhitespace: (input: string) => boolean; /** * 判断字符串是否为小写字母 * @param {string} input 输入字符串 * @example * isAllLowerCase('abcdefg'); => true * isAllLowerCase('isAllLowerCase'); => false */ const isAllLowerCase: (input: string) => boolean; /** * 判断字符串是否为大写字母 * @param {string} input 输入字符串 * @example * isAllUpperCase('ABCDEFG'); => true * isAllUpperCase('isAllLowerCase'); => false */ const isAllUpperCase: (input: string) => boolean; /** * 如果字符串为空则使用默认字符串, 否则不变 * @param {string} input 输入字符串 * @param {string} defaultStr 输入字符串 * @example * defaultIfEmpty('', 'abcd'); => 'abcd' * defaultIfEmpty('我是测试的字符串isAllLowerCase', '我是测试的字符串'); => '我是测试的字符串isAllLowerCase' */ const defaultIfEmpty: (input: string, defaultStr: string) => string; /** * 字符串反转 * @param {string} input 输入字符串 * @example * reverse('abcd'); => 'dcba' * reverse('ABCD'); => 'DCBA' */ const reverse: (input: string) => string; /** * 删掉特殊字符(英文状态下) * @param {string} input 输入字符串 * @example * removeSpecialCharacter('remove SpecialCharacter$%%^'); => 'remove SpecialCharacter' * removeSpecialCharacter('removeSpecialCharacter##*'); => 'removeSpecialCharacter' */ const removeSpecialCharacter: (input: string) => string; /** * 只包含特殊字符、数字和字母 * @param {string} input 输入字符串 * @example * isSpecialCharacterAlphanumeric('2222SpecialCharacter$%%^'); => true * isSpecialCharacterAlphanumeric('(字符串2222SpecialCharacter$%%^)'); => false */ const isSpecialCharacterAlphanumeric: (input: string) => boolean; /** * 中文校验 * @param {string} input 输入字符串 * @example * isChinese('我是测试的字符串'); => true * isChinese('我是测试的字 abc 符串'); => false */ const isChinese: (input: string) => boolean; /** * 去掉中文字符 * @param {string} input 输入字符串 * @example * removeChinese('我是测试的字 abc 符串'); => abc * removeChinese('测试abcd'); => abc */ const removeChinese: (input: string) => string; /** * 转义元字符 * @param {string} input 输入字符串 * @example * escapeMetacharacter('\'\''); => '\'\'' * escapeMetacharacter('\n\\?'); => '\n\\?' */ const escapeMetacharacter: (input: string) => string; /** * 转义字符串中的元字符 * @param {string} input 输入字符串 * @example * escapeMetacharacterOfStr('\'\''); => '\'\'' * escapeMetacharacterOfStr('我是测试的字abc\n符串'); => '我是测试的字abc\n符串' */ const escapeMetacharacterOfStr: (input: string) => string; /** * 将中划线分隔形式的字符串,转换为驼峰式的字符串 * @param {string} input 输入字符串 * @example * camelize('last-index-of'); => 'lastIndexOf' * camelize('escape-metacharacter-of-str'); => 'escapeMetacharacterOfStr' */ const camelize: (input: string) => string; /** * 将驼峰式的字符串转换为中划线分隔形式的字符串 * @param {string} input 输入字符串 * @example * hyphenate('lastIndexOf'); => 'last-index-of' * hyphenate('escapeMetacharacterOfStr'); => 'escape-metacharacter-of-str' */ const hyphenate: (input: string) => string; /** * 将下划线分隔形式的字符串转换为驼峰式的字符串 * @param {string} input 输入字符串 * @example * camelize('last_index_of'); => 'lastIndexOf' * camelize('escape_metacharacter_of_str'); => 'escapeMetacharacterOfStr' */ const uncamelize: (input: string) => string; /** * 将驼峰式的字符串转换为下划线分隔形式的字符串 * @param {string} input 输入字符串 * @example * hyphenate('lastIndexOf'); => 'last_index_of' * hyphenate('escapeMetacharacterOfStr'); => 'escape_metacharacter_of_str' */ const unhyphenate: (input: string) => string; /** * 检测密码强度 * @param {string} str 密码 * @example * checkPwd('data123') => 2 */ const checkPwd: (str: string) => number; /** * html转换文本 * @export * @param {string} str html代码段 * @example * filterTag('
你好
') => 你好 */ const filterTag: (str: string) => string; } export default StringUtil;