The regex where you read in file 2 has a couple of issues. First, it forces start and end of line matching (^ and $, respectively). Next, it only matches the pipe and the whitespace on either side of it, so it will only match lines with ' | \n'. Lastly, it deletes everything that it matches.
The pipe character, if un-escaped means "or" in a regex. This regex would delete the white space in a line containing only white space - not too useful. I don't see that /g does anything. Not sure what the OP wanted to happen. But you are right, this almost assuredly not it.
In reply to Re^2: Question on file compare
by Marshall
in thread Question on file compare
by sureshsmr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |