Retrieving tokens while taking quotes and escape characters into account

Viewed 33

I have a node script that reads lines of input from a file where each line is formatted like this:

https://youtu.be/hdA_rpOXFws Ouroboros\ ~Infinite\ Circulation~ "Ouroboros ~Infinite Circulation~" VOEZ DLight
...
...
...

I want to split these lines into tokens such that the first token will be https://youtu.be/hdA_rpOXFws, then Ouroboros ~Infinite Circulation~, then Ouroboros ~Infinite Circulation~, then VOEZ, then DLight. Currently my solution revolves around manually going through and checking each space to see if the character is escaped or if there is a quote after it and manually finding the next quote but making sure it's not escaped, but this is headache-inducing. Is there an easy built-in way to do this?

As for why I'm doing this, yes

0 Answers
Related