Here is a list of 30 English nouns in their singular and plural form. Your job is simply to write the shortest regular expression that matches all the nouns in one form and none in the other (easy, all English nouns end in s
in plural form right?).
SINGULAR PLURAL
--------- --------
car cars
boat boats
man men
woman women
omen omens
bus buses
cactus cacti
spy spies
pie pies
louse lice
mouse mice
amice amices
goose geese
creese creeses
person people
child children
siren sirens
ox oxen
foot feet
tooth teeth
formula formulae
minx minxes
sphinx sphinges
wife wives
knife knives
ion ions
criterion criteria
jinni jinn
zero zeros
hero heroes
Yes, some of the words have alternative forms, but these are the ones we're going to use.
Here is a script that can help you with the testing; just put your regex between the two slashes (/
) on the first line.
fish
andsheep
to the list :) \$\endgroup\$