var myString = '\\folder\folder1\folder2\folder3\anotherFolder\filname.pdf';
The goal is to get
myString = '\\\\folder\\folder1\\folder2\\folder3\\anotherFolder';
My first idea was to split on each backslash, do a loop to create the new string. I got this result for the split
myString.split('\\'); ["", "folderolder1older2older3anotherFolderilname.pdf"]
\fis just an escaped characterf.\fis a single character.'\f'.length === 1and'\f'.charCodeAt(0)it returns 12, the Form Feed character: unicode-table.com/en/000C