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

163
Views
Dos "=" caracteres en una cadena

Cómo verificar en javascript si en la cadena hay dos símbolos "=" y arrojar un error (porque, por ejemplo, 1+=2=3 es incorrecto pero 1+2=3 es correcto)

about 4 years ago · Santiago Gelvez
3 answers
Answer question

0

 function validateText() { const text = document.getElementById('text').value; if ((text.match(/=/g)?.length || 0) < 2) { document.getElementById('result').innerHTML = "Valid"; } else { document.getElementById('result').innerHTML = "Invalid"; } }
 <textarea id="text"></textarea> <button onclick=validateText()>Validate</button> <p id="result"></p>

about 4 years ago · Santiago Gelvez Report

0

var input_true = '1 + = 2 + 3'; var input_false = '1 + = 2 + = 3'; var success = /^[^=]*=[^=]*$/.test(input_true); // pass var not_success = /^[^=]*=[^=]*$/.test(input_false); // fails
about 4 years ago · Santiago Gelvez Report

0

Escriba una pequeña función que use una expresión regular para probar esto.

 function tester(str) { return str.match(/=/g).length === 1; } console.log(tester('=')); console.log(tester('Bob==')); console.log(tester('Bob=')); console.log(tester('=Bob=='));

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