'How do I get long lists of information into an array?

I am trying to build a variation of wordle in javascript+html and I need the list of all the possible wordle words in an array. I have the words in a list like this that includes all of the several thousand words. But I don't know how to make this into an array. Manually typing in thousands of them doesn't seem like a feasible solution. How can I turn a typed out list like this into an array in javascript? segment of my list of wordle words

I tried to put it into a java program that used a scanner to get all the inputs and print it out into a form with the " and [ as needed so then I could just copy the line and put it into my javascript code but with nearly thirteen thousand lines, my scanner was bugging and not reading all the words. I need a complete list. I am guessing there is some way to just do it all through javascript/html but I don't know what it is. Can someone please show me how to turn a list like this with nearly thirteen thousand values into a javascript array?



Solution 1:[1]

Copy the text into a textbox, then have a button that matches all lines or word characters and gives you a stringified output.

document.querySelector('button').addEventListener('click', () => {
  document.querySelector('#output').value = JSON.stringify(
    document.querySelector('#input').value
      .split('\n')
      .filter(Boolean) // just in case there are empty lines
  );
});
<textarea id="input" placeholder="foo
bar"></textarea>
<div><button>transform</button></div>
<textarea id="output"></textarea>

Then you can copy that into an array declaration statement in your code.

Another option would be to find-and-replace with regex in VSCode (or some editor) - match word characters and replace with those word characters surrounded by "s, with , at the end. Add the array delimiters manually.

https://regex101.com/r/0f5aou/1

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 CertainPerformance