Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8431557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:53:13+00:00 2026-06-10T05:53:13+00:00

Recently, I started to make a word game which involves making words out of

  • 0

Recently, I started to make a word game which involves making words out of the letters of another word. For example, if you have the word “Teutonic”, you could make “tonic”, “tone”, etc. In the game, you can only use the available letters in the word, and not repeat them. That means that while “tonic” would be valid in the above example, “tonico” would not because there is only one “o” in “Teutonic”.

My question is basically, how can I make a regular expression so that it searches for one instance of the letter and remembers it so that, given the same letter later in the loop, doesn’t look for it again?

So if you have “Teutonic” and you are searching using a regex for each letter in “tonico” (“t”,”o”,”n”,”i”,”c”,”o”), you would get “true” for every one, except for the last “o”.

If you have the word “Pencil”, you would get true for “pen”, “line”, and “pile”, but not from “Pipe”.

Or if you have “small”, you would get true for “mall”, “malls” but not “mass”.


Edit:

Thank you very much for all of your prompt replies!
I suspected that it wasn’t going to be possible with a regex approach, but I wanted to make sure. Instead, I experimented a bit with the array method, thought I didn’t get very far.

Thanks again guys!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:53:15+00:00Added an answer on June 10, 2026 at 5:53 am

    Split the string to array, and then compare with array.

    function checkStr(str1, str2) {
      var arr1 = str1.split(''),
          arr2 = str2.split(''),
          i,j;
      for (i = 0; i < arr2.length; i++) {
         if ((j= arr1.indexOf(arr2[i])) === -1) {
            return false;
         } 
         arr1.splice(j, 1);
      }
      return true;
    }
    // usage
    checkStr('small', 'mall');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have recently started learning Silverlight and can't figure out how make this work.
I have recently started using the Rackspace Cloudfiles CDN (Limelight), about which I have
I have recently started a new C++ project and I intend to make it
I have recently started to make useful use of C# extension methods. The SO
I have recently started a fairly large web project which is going to use
I have recently started learning Perl and one of my latest assignments involves searching
I've recently started learning programming to make my own 3D OpenGL game on the
I just recently started making apps for OSX desktops and I want to have
We recently started making use of the new Google Expansion APK mechanism. Overall it
I recently started programming C on Mac OS X (10.7.4). I have the various

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.