relatica/lib/utils/string_utils.dart
2024-08-29 20:31:43 -04:00

18 lines
440 B
Dart

import 'package:intl/intl.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@?^=%&/~+#-])?"),
"");
}
final decimalWithCommasFormat = NumberFormat("#,##0.###");