Execute Program

Regular Expressions: Or

Welcome to the Or lesson!

This lesson is shown as static text below. However, it's designed to be used interactively. Click the button below to start!

  • Sometimes we need to allow multiple alternatives. We can separate them with a pipe character, |, pronounced "or".

  • >
    /a|b/.test('a');
    Result:
    truePass Icon
  • >
    /a|b/.test('b');
    Result:
    truePass Icon
  • >
    /a|b/.test('c');
    Result:
    falsePass Icon
  • >
    /at|og/.test('cat');
    Result:
    truePass Icon
  • >
    /at|og/.test('dog');
    Result:
    truePass Icon
  • >
    /at|og/.test('bat');
    Result:
    truePass Icon
  • >
    /at|og/.test('horse');
    Result:
    falsePass Icon