Alternations

What if we want to match multiple strings? Say, we want to match the texts one, two, three, four, and five:

'one' | 'two' | 'three' | 'four' | 'five'

It’s that easy, just separate all alternatives with a vertical bar. This is called an alternation. The | can be read as “or”, since the above matches 'one' or 'two' or 'three' or 'four' or 'five'.

Grouping

If we want to concatenate an alternation, we need to wrap it in parentheses:

('blue' | 'yellow' | 'green') 'ish'

This matches blueish, yellowish, and greenish. Every expression can be surrounded by parentheses, this is called a group. Here the parentheses are needed to clarify that the ish is concatenated with the entire alternation, not just the green part.

Formatting

When your expression gets so long that it doesn’t fit in a single line, it looks better to put every alternative in a separate line:

'one'
| 'two'
| 'three'
| 'four'
| 'five'

But this looks odd, because the first line is not aligned with the others. So Pomsky allows you to add a leading vertical bar:

| 'one'
| 'two'
| 'three'
| 'four'
| 'five'