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

130
Views
Quiere escribir expresiones regulares en javascript que verificará si todos los caracteres mencionados existen al menos unos

Tengo cadenas y necesito verificar si esa cadena contiene todos los alfabetos de la a a la z. ¿Cuál será la expresión regular para verificar esta condición? donde s puede ser una cadena muy grande con varias palabras separadas por espacios.

ex:

 pattern.test("zy aemnofgbc jkhil pqasdfrs tuvrhfwx")

debería devolver verdadero ya que contiene todos los alfabetos az al menos unos.

 pattern.test("sdfasbcd effsdgh ijsfghtkl mnhtop qrsjht uvwmnmx yfdhjkd")

debería devolver falso ya que no tiene el alfabeto z.

Buscando la solución óptima.

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

la forma más fácil es extrayendo caracteres únicos

 function testAlphabet(str) { var chars = str.replace(/[^az]/g).split(''); // it may need to convert to lowercase // remove duplicate chars = [...new Set(chars)]; console.log(chars.join('').length == 26) } testAlphabet("zy aemnofgbc jkhil pqasdfrs tuvrhfwx") testAlphabet("sdfasbcd effsdgh ijsfghtkl mnhtop qrsjht uvwmnmx yfdhjkd")

about 4 years ago · Juan Pablo Isaza Report

0

Primera solución con expresiones regulares: elimina todos los caracteres no alfabéticos, los duplica y compara la longitud de la cadena con 26.

Segunda solución sin expresiones regulares, solo verifica todos los caracteres alfabéticos en la cadena.

 const test1 = (str) => str.replace(/[^az]|(.)(?=.*\1)/gi, '').length === 26; const test2 = (str) => [...`abcdefghijklmnopqrstuvwxyz`] .every(ch => str.includes(ch)); console.log(test1('zy aemnofgbc jkhil pqasdfrs tuvrhfwx')); console.log(test1('y aemnofgbc jkhil pqasdfrs tuvrhfwx')); console.log(test2('zy aemnofgbc jkhil pqasdfrs tuvrhfwx')); console.log(test2('y aemnofgbc jkhil pqasdfrs tuvrhfwx'));
 .as-console-wrapper{min-height: 100%!important; top: 0}

about 4 years ago · Juan Pablo Isaza Report

0

es todo az

 function isAllaz() { let s = "zy aemnofgbc jkhil pqasdfrs tuvrhfwx"; //console.log([...new Set(s.split("").filter(e => e.match(/[az]/)))].length==26); return [...new Set(s.split("").filter(e => e.match(/[az]/)))].length==26; }
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!