Skip to content
TheChatArchiveThe Chat Archive
Human-written demonstration (OpenAssistant volunteers)· OpenAssistant (human-written)Hugging Face OpenAssistant Conversations (oasst2)

What is the right regex to make sure an answer is exclusively Japanese Kana?

In OpenAssistant data, “assistant” turns were written by human volunteers as demonstrations. They are not model outputs.
  1. User

    What is the right regex to make sure an answer is exclusively Japanese Kana?

  2. Assistant

    You can use the following regular expression pattern to ensure that an answer consists exclusively of Japanese Kana characters:

    ^[\p{Script=Hiragana}\p{Script=Katakana}ー-]+$

    Explanation:

    • ^ - Matches the start of the string.

    • [\p{Script=Hiragana}\p{Script=Katakana}ー-] - Character class that allows matching of either Hiragana characters, Katakana characters, or the long vowel mark (ー) and its half-width counterpart (-).

    • "+ -" Allows one or more occurrences of the character class.

    • $ - Matches the end of the string.

    This regular expression pattern will only match strings that consist entirely of Hiragana characters, Katakana characters, or the long vowel mark. It will exclude any other characters such as Kanji, numbers, or Latin characters.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.