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

185
Visualizações
Convert $x()'s return value to individual strings in browser console (one liner)?

How can I convert the return value of an XPath search $x(), when executed in a browser console, to individual strings so that I can perform string manipulations on the result in a "one-liner"?

Imagine that I run a $x() and the result is three values:

abc
def
ghi

I then want to extract the first letter from each of these result, using something like 'abc'.match("."). It has to be a "one-liner" because the purpose is to distribute it to non-technical users that should be able to just copy-paste it into the console.

Error handling is not necessary.

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

This Google Chrome console one-liner,

$x('//span').map(e => e.textContent.charAt(0))

will return an array of the first characters of the text content of every span element of the current page. Update the XPath side (//span) or the JavaScript side (.map(e => e.textContent.charAt(0)))) as needed for your particular case.

about 4 years ago · Santiago Trujillo 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