JAVA QUESTION Write regular expressions after the to validat
JAVA
QUESTION:
-Write regular expressions after the to validate the following inputs:
a) Product codes that have one or more letters followed by one or more digits.
b) Nonnegative integers between 1,000 and 9,999, including the comma.
c) Canadian zip code containing upper case characters only.
d) License plate numbers that have the form:
Letter
Digit
Letter
Hypen (-)
Digit
Letter
Digit
Solution
a)product code having zero or more letters followed by one or more digits
b)non negative numbers between 1000 to 9999
[1-9][0-9][0-9][0-9][\\,]
C)canadian zipcode
^[ABCEGHJKLMNPRSTVXY]{1}\\d{1}[A-Z]{1}*\\D{1}[A-Z]{1}\\d{1}$
d) to print license plate with mentioned format
^[a-zA-Z0-9a-zA-Z-0-9a-zA-Z0-9]*$
