013-004-006
Check String Match with Regex
Easy
Problem Description
Check String Match with Regex
In this problem, you will create a program that reads two strings from Scanner, uses String.matches() with the regex pattern [A-Za-z]+[0-9]+ to determine whether each string matches the pattern, and displays the result to standard output.
Learning Objective: Understand the basics of string pattern matching with regex using String.matches() method
Overview
Create a program that reads two strings from standard input and uses regex to determine whether each string matches a specific pattern.
Input Format
text1
text2
Specifications
- Read string text1 from the first line of standard input
- Read string text2 from the second line of standard input
- Use regex pattern
"[A-Za-z]+[0-9]+"(letters followed by numbers) - Output whether each string matches the pattern
Output Format
value_of_text1: true/false
value_of_text2: true/false
Example
Input:
Hello123
Hello
Output:
Hello123: true
Hello: false
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up