1import java.util.regex.Matcher;
2import java.util.regex.Pattern;
3public class Just {
4 public static void main(String[] args) {
5 String data = "abc12def334hjdsk7438dbds3y388";
6 //Regular expression to digits
7 String regex = "([0-9]+)";
8 //Creating a pattern object
9 Pattern pattern = Pattern.compile(regex);
10 //Creating a Matcher object
11 Matcher matcher = pattern.matcher(data);
12 System.out.println("Digits in the given string are: ");
13 while(matcher.find()) {
14 System.out.print(matcher.group()+" ");
15 }
16 }
17}