Question 7 (DS)

There is a list of 20 words. 10 of them are good works, and 10 of them are bad words. Write a regex of not more than 25 characters which would tell if given word is good or bad. Input would only contain one of these 20 words.

Good words: papa, book, home, cars, jolly, sugar, friend, mother, father, bloomiest

Bad words: ache, slow, torn, slum, boom, rival, wrong, cholera, revenge, arrogant

Input: book

Output: Good

Input: boom

Output: bad

Write Java Code using regex pattern

New Report