Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

150
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!