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

151
Visualizações
Google Apps Script not recognizing strings with parentheses and brackets as part of the string

I have a conditional that is supposed to compare two strings:

if (parametros.toString().toLowerCase().match(valor_celda_activa.toString().toLowerCase()) != null){
...actions here...
}

This works ok UNTIL there is some parentheses or bracket inside the string.

Working example strings:
parametros = "1.01 - Sourcing Gathering information"
valor_celda_activa = "1.01 - Sourcing Gathering information"

NOT working example strings:
parametros = "1.01 - [Sourcing] Gathering information"
valor_celda_activa = "1.01 - [Sourcing] Gathering information"

Note the brackets inside the strings. As long as the brackets are present, the code won't work. This also happens with parentheses.

Haven't actually found this kind of specific situation from someone else on the internet.

This is really my first question on StackOverFlow so feel free to feedback or request more information that I might have missed.

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

0

String.match expects a regular expression. Square brackets [] have special meaning in regex. For plain text matching, just use ===:

if (parametros.toString().toLowerCase() === valor_celda_activa.toString().toLowerCase()){
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