Chanukah Regex

According to http://www.holidays.net/chanukah/spelling.htm, it can be spelled any of the following ways:

Chanuka
Chanukah
Chanukkah
Channukah
Hanukah
Hannukah
Hanukkah
Hanuka
Hanukka
Hanaka
Haneka
Hanika
Khanukkah

Here is my regex that matches all of them:

/(Ch|H|Kh)ann?[aeiu]kk?ah?/

Edit: Or this, without branches:

/[CHK]h?ann?[aeiu]kk?ah?/

Call me a sucker for readability.

In Python:

def find_hanukkah(s):
   import re

   spellings = ['hannukah', 'channukah', 'hanukkah'] # etc...

   for m in re.finditer('|'.join(spellings), s, re.I):
      print m.group()



find_hanukkah("Hannukah Channukah, Hanukkah")

Tags:

Regex