regex

Different spellings of Chanukah Regex


Hannuka, Chanukah, Hanukkah...Due to transliteration from another language and character set, there are many ways to spell the name of this holiday. How many legitimate spellings can you come up with?

Now, write a regular expression that will recognise all of them.


Solution

  • 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?/