5
Setting:
const texto = 'ABC [abc] a-c 1234';
console.log(texto.match(/[A-z]/g))
- Why the set of
A(maiúsculo)
untilz(minusculo)
, that is to say,/[A-z]/g
returned me to[
and]
? - The result should not be:
[A, B, C, a, b, c, a, c]
?
5
const texto = 'ABC [abc] a-c 1234';
console.log(texto.match(/[A-z]/g))
A(maiúsculo)
until z(minusculo)
, that is to say,
/[A-z]/g
returned me to [
and ]
?[A, B, C, a, b, c, a, c]
?9
[A-z]
will match ASCII characters in the sequence of A
to z
. If you look at ascii table below you will see that there are several other characters between A
and z
(including the square brackets []
that you don’t want).
How you wish to marry only uppercase and lowercase letters, from A
to Z
and of a
to z
, the correct would be to use [a-zA-Z]
.
const texto = 'ABC [abc] a-c 1234';
console.log(texto.match(/[a-zA-Z]/g))
5
The crease or intervals follow the table Unicode.
I defined that my set should be A(maiúsculo) até z(minusculo)
, there are symbols in the middle of that range.
It’s them: [ \ ] ^ _ `
Look at the Unicode table:
The first 127 characters of the Unicode table are the same as in the table ASCII
Browser other questions tagged regex
You are not signed in. Login or sign up in order to post.