Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

97
Visualizações
The "no-character space" between two characters in REGEX Javascript

As we can split an array from a Regex, I try to understand this:

console.log( 'hello'.split(/([a-z])/g) );
// returns ['', 'h', '', 'e', '', 'l', '', 'l', '', 'o', '']

The return should be [ 'h', 'e', 'l', 'l', 'o']

How could I use this "no-character" in a Regex and what it represents in computer science?

I find this: Non-breaking space I tried:

let carac = String.fromCharCode(parseInt('202F', 16));
'hello'.split(carac);

But it not works.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

console.log( 'hello'.split(/([a-z])/g) );
// returns ['', 'h', '', 'e', '', 'l', '', 'l', '', 'o', '']

The return should be [ 'h', 'e', 'l', 'l', 'o']

No, it shouldn't. First of all, you're opting in to use a very specific syntax (source):

If separator is a regular expression that contains capturing parentheses ( ), matched results are included in the array.

So you're getting both results (empty strings) and separators (letters). If you omit the capturing parenthesis you'll only get results:

console.log( 'hello'.split(/[a-z]/g) );

Getting [ 'h', 'e', 'l', 'l', 'o'] would mean you're getting the separators only. There isn't such syntax defined. To get those as result you need to use the appropriate separator, which is "none at all" (represented by an empty string):

console.log( 'hello'.split('') );

Last but not least, non-breaking spaces are regular characters such as k or 🦄 that a string can contain, their main peculiarity being that they are invisible. They aren't abstractions as you seem to assume.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda