I have a string that varies in line length that goes in this format::
file/path
hash
file/path
hash
I want to get rid of every line that is a file path and put it into a new variable, and I want to do the opposite, removing every line that isn’t a file path and putting it into a new variable.
Here’s my current solution:
var regex = /\n|.+|\n/
var fixedtochashes = fixedtoc.replace(regex, “”);
This works for the first line, but it only works for the first line. So naturally I added “g” to the end of the regex variable:
var regex = /\n|.+|\n/g
var fixedtochashes = fixedtoc.replace(regex, “”);
And this solution just replaces every line. Anyone know how to fix this?