bhylu.com

Advertisements

JS RegExp Patterns

Build a pattern from a clear input rule. This small pattern accepts a simple workshop code, not every possible identifier.

Where to run this

This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.

A practical example

JavaScript

const pattern = /^[A-Z]{2}-\d{3}$/;
console.log(pattern.test("RC-204"));

What happens

RC-204 follows the chosen rule.