I have a file say File1.Now i need a specific pattern from the lines to be added to the other line. File red blue green ABC.txt@ABC END black ash grey purple XYZ.txt@XYZ orange pink yellow marroon PQR.txt@PQR Now i want the file to look like this<br> #change ABC red blue green ABC.txt@ABC END #change XYZ black ash grey purple XYZ.txt@XYZ END #change PQR orange pink yellow marroon PQR.txt@PQR END
so, first you would iterate over the list and Inject an End at the end, and after ever regex.match of (/@/), then iterate again, and if the next one in line = END, then, put a # char. then, split on "END", add a # at the beginning from the first of the match and concatenate all back together