Advertisement
SIRAKOV4444

Untitled

Apr 7th, 2020
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.util.regex.Matcher;
  3. import java.util.regex.Pattern;
  4.  
  5. public class practice {
  6. public static void main(String[] args) {
  7. Scanner sc = new Scanner(System.in);
  8. String regex = "([0-9]+)";
  9. String example = "99999";
  10.  
  11. Pattern pattern = Pattern.compile(regex);
  12. Matcher matcher = pattern.matcher(example);
  13.  
  14. String tiPrint = matcher.group(0);
  15. System.out.printf("%s",tiPrint);
  16.  
  17. }
  18. }
  19.  
  20. Exception in thread "main" java.lang.IllegalStateException: No match found
  21. at java.base/java.util.regex.Matcher.group(Matcher.java:645)
  22. at practice.main(practice.java:14)
  23.  
  24. Process finished with exit code 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement