For example, I have a set of text "1234568asdjhgsd", I just want to get the number, what should I do? The following is my code, he can't execute it to the while step
textView.setText("1234568asdjhgsd");
String str = (String) textView.getText();
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Pattern p;
p = Pattern.compile("\\d{10}");
Matcher m;
m = p.matcher(str);
while (m.find()){
String xxx = m.group();
System.out.println(xxx);
}
}
});
It didn't print anything