relatica/lib/utils/string_utils.dart

15 wiersze
349 B
Dart

extension StringUtils on String {
String truncate({int length = 32}) {
if (this.length <= length) {
return this;
}
return '${substring(0, length)}...';
}
String stripHyperlinks() =>
replaceAll(RegExp(
r"(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?"),
"");
}