Why is 'B' matched by [a-z]?

javascript, regex

Solution

Yes, but you have the `i` parameter which tells the regex to ignore case.

From the MDN documentation for RegEx:

Parameters

pattern

The text of the regular expression.

flags

If specified, flags can have any combination of the following values:

...

`i`

ignore case

Problem

a very simple & naive question: why this is true? ``` new RegExp('^[a-z]+$', 'i').test('B') ``` apparently 'B' is out of [a-z]?

Original source