StrUtils class
create_user: zhengzaihong email:1096877329@qq.com create_date: 2022/7/4 create_time: 17:34 describe: 文本处理工具 text processing tools
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
camelToSnake(
String str) → String - 驼峰命名转下划线命名 Convert camel case to snake case
-
capitalize(
String str) → String - 首字母大写 Capitalize first letter
-
capitalizeAll(
String str) → String - 每个单词首字母大写 Capitalize each word
-
countOccurrences(
String str, String character) → int - 计算字符串中某个字符的出现次数 Count occurrences of a character in string
-
desensitize(
String str, {int start = 0, int? end, String replace = '*'}) → String - 字符串脱敏处理 Desensitize string
-
endsWithIgnoreCase(
String str, String suffix) → bool - 检查字符串是否以指定后缀结尾(忽略大小写) Check if string ends with suffix (case insensitive)
-
equals(
String? a, String? b) → bool - 检查两个字符串是否相等 Check whether two strings are equal
-
extractLetters(
String str) → String - 提取字符串中的字母 Extract letters from string
-
extractNumbers(
String str) → String - 提取字符串中的数字 Extract numbers from string
-
firstChineseCharacter(
String str) → String? - 获取字符串中的第一个汉字 Get first Chinese character from string
-
firstLetter(
String str) → String? - 获取字符串中的第一个字母 Get first letter from string
-
firstNullToSecond(
String? first, String? second, {String def = ''}) → String - 如果第一项为空则返回第二项, def可选返回默认值 Returns the second item if the first item is empty, def optionally returns the default value
-
firstNumber(
String str) → String? - 获取字符串中的第一个数字 Get first number from string
-
hasAz(
String str) → bool -
【含有英文】true
Contains letters
true -
hasNum(
String str) → bool -
【含有数字】true
Contains numbers
true -
hideEmail(
String email, {int start = 1, String replace = '*'}) → String - 隐藏部分邮箱 Hide part of email
-
hidePhone(
String phone, {int start = 3, int end = 7, String replace = '*'}) → String - 隐藏部分手机号 Hide part of phone number
-
insertSeparator(
String str, {int interval = 4, String separator = ' '}) → String - 插入分隔符 Insert separator
-
isAz(
String str) → bool -
【全为字母】返回true 否则false
All letters
Returns true otherwise false -
isAzNum(
String str) → bool -
【除字母和数字外无其他字符(只有字母数字的字符串)】返回true 否则false
No characters except letters and numbers (only alphanumeric strings)
Returns true Otherwise false -
isChinese(
String str) → bool - 判断是否为纯中文,不是返回false Determine whether it is pure Chinese, not return false
-
isEmail(
String str) → bool - 判断是否为邮箱格式 Check if it is email format
-
isEmpty(
String? string) → bool - 检查字符串是否为空 Check whether the string is empty
-
isIdCard(
String str) → bool - 判断是否为身份证格式 Check if it is ID card format
-
isNotEmpty(
String? string) → bool -
isNum(
String str) → bool -
【全为数字】返回true
All numbers
Returns true -
isPhone(
String str) → bool - 判断是否为手机号格式 Check if it is phone number format
-
isUrl(
String str) → bool - 判断是否为URL格式 Check if it is URL format
-
lengthWithChinese(
String str) → int - 计算字符串长度(中文算两个字符) Calculate string length (Chinese characters count as two)
-
matchesPattern(
String str, String pattern) → bool - 验证字符串是否匹配正则表达式 Validate string against regex pattern
-
nullToDef(
String? value, String def, {String? suffix, bool defSuffix = false}) → String - 如果为空返回默认值def, defSuffix为true时拼接上后缀 suffix if it is empty, return the default value def, and if defSuffix is true, append the suffix suffix
-
removeAllSpace(
String str) → String - 去除所有空格 Remove all spaces
-
removeExtraSpace(
String str) → String - 去除多余空格(保留一个) Remove extra spaces (keep one)
-
removeHtmlTags(
String str) → String - 移除字符串中的HTML标签 Remove HTML tags from string
-
reverse(
String str) → String - 字符串反转 Reverse string
-
snakeToCamel(
String str) → String - 下划线命名转驼峰命名 Convert snake case to camel case
-
startsWithIgnoreCase(
String str, String prefix) → bool - 检查字符串是否以指定前缀开头(忽略大小写) Check if string starts with prefix (case insensitive)
-
truncate(
String str, int maxLength, {String ellipsis = '...'}) → String - 截断字符串,添加省略号 Truncate string with ellipsis