Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this assignment you will use regular expression How to validate time in 2 4 - hour format using Regular Expression Given a string str
In this assignment you will use regular expression
How to validate time in hour format using Regular Expression
Given a string str the task is to check whether the string is valid time in hour format or not
by using Regular Expression.
The valid time in the hour format must satisfy the following conditions.
It should start from or
It should be followed by a :colon
It should be followed by two digits from to
It should not end with ampm or AMPM
Examples:
Input: str :
Output: true
Explanation: The given string satisfies all the above mentioned conditions.
Input: str :
Output: true
Explanation: The given string satisfies all the above mentioned conditions.
Input: str :
Output: false
Explanation: The given string doesnt be in the range of or ie hour is out of
range therefore it is not a valid time in hour format.
Input: str :
Output: false
Explanation: The given string doesnt be in the range of to ie minute is out of range
therefore it is not a valid time in hour format.
Input: str : PM
Output: false
Explanation: The given string end with AM or PM therefore it is not a valid time in hour
format.
Note : You are recommended to use Java
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started