Advertisement
pedrolemoz

Phone

Apr 22nd, 2024
724
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 0.30 KB | None | 0 0
  1. void main() {
  2.   final phone = '+55 85 88888-8888';
  3.   final replacement = phone.replaceAllMapped(
  4.     RegExp(r'(\d*)\s(\d*)\s(\d*)\-(\d*)'),
  5.     (match) =>
  6.         '${match[1]} ${match[2]} ${match[3]?.replaceAll(RegExp(r'\d'), '*')}-${match[4]}',
  7.   );
  8.  
  9.   print(phone);
  10.   print(replacement);
  11. }
  12.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement