Thanks a lot for your responses! nvivek's post worked, however, there is just one slight bug. This will produce an output that includes spaces and newline characters, which are unwanted. I tried to change the regex to /\w+/, because this says that there will be only alphanumeric strings plus underscores, but this produces an empty output.
I just don't understand why it would produce characters with a // regex, but nothing with /\w+/