-1

I get a string into a variable user_input that is generated from the user, this string has different characters and line separators, within the string there is an expression that has this pattern
(abcd efgh ijkl) where the letters are random integers.

How do i check for and obtain the expression that meets this pattern from user_input?

John Kaita
  • 15
  • 8

1 Answers1

0
import java.util.regex.Pattern;

System.out.println(Pattern.matches("\\d{4}\\s+\\d{4}\\s+\\d{4}", input));
Zaven Zareyan
  • 1,360
  • 8
  • 15