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

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

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 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!