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

144
Visualizações
How to get a specific string in JavaScript

I have:

var text = 'LTE CSSR (East xr) (301-LT_King_St_PC)'

and I want to split from (East xr) (301-LT_King_St_PC) only as follow :

var result = text.split('(')
result = (East xr) (301-LT_King_St_PC)
about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

You can use a regular expression with the match function to get this done. Depending on how you want the result try one of the following:

var text = 'LTE CSSR (East xr) (301-LT_King_St_PC)'
console.log('one string:', text.match(/\(.*\)/)[0])
console.log('array of strings:', text.match(/\([^\)]*\)/g))

The first does what you seem to be asking for - a single output of everything between the first ( and the second ). It does this by searching for /\(.*\)/ which is a regex that says "everything in between the parentheses".

The second match splits it into all parenthesised strings using /\([^\)]*\)/g which is a regex that says "each parenthesised string" but the g at the end says "all of those" so an array of each is given.

about 4 years ago · Juan Pablo Isaza Relatório

0

You can do it using substring() and indexOf() :

var text = 'LTE CSSR (East xr) (301-LT_King_St_PC)';
var result = text.substring(text.indexOf('('));
console.log(result);

about 4 years ago · Juan Pablo Isaza Relatório

0

You're quite close with your current method. One way you could try this is to use multiple characters within your split

var result = text.split(") (") 
# Output -> result = ["(East xr", "301-LT_King_St_PC)"]

From here, some string manipulation could get rid of the brackets.

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