Java question about regular expressions Consider the following regular expressio
ID: 3843421 • Letter: J
Question
Java question about regular expressions
Consider the following regular expression inside a Java String: String expression = "([1-9]|[1-6][0-9])[A-K]"; Write four public strings s1m, s2m, s3n, s4n as public String s1m = "ellipsis"; public String s2m = "ellipsis"; public String s3n = "ellipsis"; public String s4n = "ellipsis"; where ellipsis is a string on which: in the case of s1m and s2m, the expression matches() in the case of s3n and s4n, the expression does not match. s1m and s2m must be of different lengths, and must not contain the same character twice, s3n and s4n must also be of different lengths and must not contain the same character twice.Explanation / Answer
Answer :
s1m="2B"
Explanation : The string is present in the expression string and its length is 2
s2m="21D"
Explanation : The string matches with the expression string and its length is 3
so the strings s1m and s2m are of different length
s3n="0LM"
Explanation : the string doesn't match with the expression string and its length is 3
s4n="11NO"
Explanation : The string doesn't match with the expression string and its length is 4
so the strings s3n and s4n are of different length
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.