const regex = /(?<phase>[0-9]+([,|.]?[0-9]+)?)[\t](?<voltage>[0-9]+([,|.]?[0-9]+)?)[\t](?<fault>[0-9]+([,|.]?[0-9]+)?)[\t](?<PD>[0-9]+([,|.]?[0-9]+)?)/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(?<phase>[0-9]+([,|.]?[0-9]+)?)[\\t](?<voltage>[0-9]+([,|.]?[0-9]+)?)[\\t](?<fault>[0-9]+([,|.]?[0-9]+)?)[\\t](?<PD>[0-9]+([,|.]?[0-9]+)?)', 'gm')
const str = `Fault location:
Cable-length (m): 266
Phase Voltage(kV) Fault(m): PD (pC):
1 11.0 141.452 142.857 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L1_11kV_2016-08-17-11'04'05.loc
1 11.0 141.452 190.476 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L1_11kV_2016-08-17-11'04'19.loc
1 11.0 141.452 161.905 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L1_11kV_2016-08-17-11'04'19.loc
1 11.0 139.673 171.429 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L1_11kV_2016-08-17-11'04'33.loc
1 11.0 141.452 152.381 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L1_11kV_2016-08-17-11'04'33.loc
1 13.0 140.562 295.238 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L1_13kV_2016-08-17-11'05'34.loc
1 13.0 137.004 285.714 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L1_13kV_2016-08-17-11'05'34.loc
1 13.0 140.562 238.095 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L1_13kV_2016-08-17-11'05'34.loc
1 13.0 142.341 200.000 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L1_13kV_2016-08-17-11'05'34.loc
1 13.0 140.562 333.333 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L1_13kV_2016-08-17-11'05'50.loc
1 13.0 139.673 314.286 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L1_13kV_2016-08-17-11'05'50.loc
3 13.0 136.114 228.571 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L3_13kV_2016-08-17-11'14'39.loc
1 13.0 136.114 171.429 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L1_13kV_2016-08-17-11'05'50.loc
1 13.0 141.452 276.190 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L1_13kV_2016-08-17-11'06'06.loc
1 13.0 139.673 180.952 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L1_13kV_2016-08-17-11'06'06.loc
2 9.0 141.452 142.857 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L2_9kV_2016-08-17-11'08'58.loc
2 11.0 136.114 304.762 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L2_11kV_2016-08-17-11'09'13.loc
2 11.0 140.562 209.524 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L2_11kV_2016-08-17-11'09'13.loc
2 11.0 138.783 285.714 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L2_11kV_2016-08-17-11'09'30.loc
2 11.0 140.562 219.048 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L2_11kV_2016-08-17-11'09'30.loc
2 11.0 139.673 333.333 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L2_11kV_2016-08-17-11'09'45.loc
2 11.0 137.004 238.095 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L2_11kV_2016-08-17-11'09'45.loc
2 13.0 140.562 447.619 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L2_13kV_2016-08-17-11'10'00.loc
2 13.0 139.673 352.381 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L2_13kV_2016-08-17-11'10'00.loc
2 13.0 137.893 323.810 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L2_13kV_2016-08-17-11'10'00.loc
2 13.0 134.335 171.429 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L2_13kV_2016-08-17-11'10'00.loc
2 13.0 140.562 447.619 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L2_13kV_2016-08-17-11'10'16.loc
2 13.0 140.562 419.048 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L2_13kV_2016-08-17-11'10'16.loc
2 13.0 138.783 390.476 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L2_13kV_2016-08-17-11'10'16.loc
2 13.0 138.783 304.762 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L2_13kV_2016-08-17-11'10'16.loc
2 13.0 140.562 200.000 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L2_13kV_2016-08-17-11'10'16.loc
2 13.0 140.562 447.619 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L2_13kV_2016-08-17-11'10'41.loc
2 13.0 138.783 409.524 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L2_13kV_2016-08-17-11'10'41.loc
2 13.0 139.673 361.905 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L2_13kV_2016-08-17-11'10'41.loc
2 13.0 137.893 352.381 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L2_13kV_2016-08-17-11'10'41.loc
3 9.0 139.673 142.857 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L3_9kV_2016-08-17-11'13'10.loc
3 11.0 120.101 342.857 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L3_11kV_2016-08-17-11'13'27.loc
3 11.0 137.893 171.429 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L3_11kV_2016-08-17-11'13'27.loc
3 11.0 139.673 219.048 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L3_11kV_2016-08-17-11'13'43.loc
3 11.0 139.673 190.476 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L3_11kV_2016-08-17-11'13'43.loc
3 11.0 139.673 304.762 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L3_11kV_2016-08-17-11'13'57.loc
3 11.0 139.673 161.905 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L3_11kV_2016-08-17-11'13'57.loc
3 13.0 137.893 380.952 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L3_13kV_2016-08-17-11'14'11.loc
3 13.0 140.562 352.381 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L3_13kV_2016-08-17-11'14'11.loc
3 13.0 139.673 352.381 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L3_13kV_2016-08-17-11'14'11.loc
3 13.0 137.893 333.333 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L3_13kV_2016-08-17-11'14'11.loc
3 13.0 140.562 200.000 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L3_13kV_2016-08-17-11'14'11.loc
3 13.0 139.673 428.571 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L3_13kV_2016-08-17-11'14'25.loc
3 13.0 140.562 409.524 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L3_13kV_2016-08-17-11'14'25.loc
3 13.0 137.004 323.810 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L3_13kV_2016-08-17-11'14'25.loc
3 13.0 136.114 209.524 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L3_13kV_2016-08-17-11'14'25.loc
3 13.0 120.101 628.571 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L3_13kV_2016-08-17-11'14'39.loc
3 13.0 140.562 314.286 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L3_13kV_2016-08-17-11'14'39.loc
3 13.0 137.893 266.667 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L3_13kV_2016-08-17-11'14'39.loc
1 13.0 139.673 238.095 C:\\Users\\z2066\\Documents\\Munka\\Diagnosztika\\KD 2016\\OWTS\\Gyor regio\\Sopron\\Frankenburg BHTR-Kossuth KTW\\L1_13kV_2016-08-17-11'05'50.loc
Joints:
0
266
`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions