removePrefixIgnoreCase static method
忽略大小写去掉指定前缀
@param str 字符串 @param prefix 前缀 @return 切掉后的字符串,若前缀不是 prefix, 返回原字符串
Implementation
static String removePrefixIgnoreCase(String? str, String prefix) {
if (isEmpty(str) || isEmpty(prefix)) {
return str ?? '';
}
final strLower = str!.toLowerCase();
final prefixLower = prefix.toLowerCase();
if (strLower.startsWith(prefixLower)) {
return str.substring(prefix.length);
}
return str;
}