⬅️ Execute Program RegEx
Basic character sets
[aou] // same as
(a|o|u)
- That was shorter, but still wordy. We can specify an entire range of characters by using
-
.
/[a-z]/.test('g');
- Character sets can be negated to mean “everything not in the set”. (
^
)
- Normally it means “beginning of line”. But inside
[]
, it means “negate the character set”.
/[^a]/.test('a'); // false
/[^ab]/.test('a'); // any char that isn't a or b
/[^a-z]/.test('h'); // false
- Character sets match exactly one character in the string (use
*
pr +
for more)