Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Textview will only show the last 4 digits numbers

Tags:

java

android

xml

My Textview is getting the data from SQLite, but I want to make Textview to show as follows:
************1234, instead of 1234123412341234.

enter image description here

like image 428
Xuezheng Low Avatar asked Aug 30 '17 15:08

Xuezheng Low


1 Answers

    String number = "grou353fp23g3qprwog9512";
    String mask = number.replaceAll("\\w(?=\\w{4})", "*");

    textView.setText(mask);

Output is *******************9512

like image 152
letsCode Avatar answered Sep 16 '22 22:09

letsCode