const indexOfSubstrings = function* (str: string, searchValue: string) {
        let i: number = 0;
        while (true) {
          const r: number = str.indexOf(searchValue, i);
          if (r !== -1) {
            yield r;
            i = r + 1;
          } else return;
        }
      };
      
      Typescript language logo

      Index of Substrings

      Codiga's TypeScript Recipes

      Finds all the indexes of a substring in a given string.

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.