Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

145
Vistas
How do I build a Regexp that doesn't care about positions

I'm making a Scrabble game with HTML and Javascript and I'd like to add a "hint word" feature based on the player's rack. I have a dictionary array with the valid words, and I need to test them against the players available tiles but I couldn't figure out how to do a regexp that gives me the following output:

Lets say the player has D-G-O-G-I-*-E tiles and the Regexp should return:

doggies = True (because of the wildcard) gore = True dog = True god = true dodge = false (because D appears only once)

It doesn't matter the order, only the letters and the times that letter is repeated

I've already tried building it with the valid letters like this /[DGOGIE]/ in regexpal.com but it didn't work at all I also tried playing with this (?=.*a)(?=.*b)(?=.*c) but still no result

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I'm not quite sure how you would do this with regex, but here is the solution that @Felix described:

function check(letters, wordToCheck) {
    for (char of wordToCheck) {
        if (letters.split(char).length - 1 < wordToCheck.split(char).length - 1) {
            return false;
        }
    }
    return true;
}

console.log(check("dgogyefi", "doggie"));
console.log(check("gepdoi", "doggie"));

(Sorry if I answered too late)

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda