const regex = /^\$\$(?<uid>\d{9})\,(?<ev>\d{4})\,(?<d>\d{2}\/\d{2}\/\d{4})?\,(?<t>\d{2}\:\d{2}\:\d{2})\,(?<lt>\-?\d{1,3}\.?\d{1,6})\,(?<ln>\-?\d{1,3}\.?\d{1,6})\,(?<al>\-?\d{1,7})\,(?<sp>\d{1,3}\.?\d{0,3})\,(?<hd>\d{1,4})\,(?<sv>\d{1,2})\,(?<hp>\d{1,3}\.?\d{1,2})\,(?<bv>\d{1,5}\.?\d{1,4})\,(?<cq>\d{1,2})\,(?<mi>\d*)\,(?<gs>[012345]{1})\,(?<gt>\d{1,5}\.?\d?)\,(?<ac>\-?\d{1,3}\.?\d{0,3})\,(?<dc>\-?\d{1,4}\.?\d{0,3})\,(?<in1s>[01]{1})\,(?<in1a>\d*)\,(?<in2s>[01])\,(?<ig>[012])\#\#/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('^\\$\\$(?<uid>\\d{9})\\,(?<ev>\\d{4})\\,(?<d>\\d{2}\\\/\\d{2}\\\/\\d{4})?\\,(?<t>\\d{2}\\:\\d{2}\\:\\d{2})\\,(?<lt>\\-?\\d{1,3}\\.?\\d{1,6})\\,(?<ln>\\-?\\d{1,3}\\.?\\d{1,6})\\,(?<al>\\-?\\d{1,7})\\,(?<sp>\\d{1,3}\\.?\\d{0,3})\\,(?<hd>\\d{1,4})\\,(?<sv>\\d{1,2})\\,(?<hp>\\d{1,3}\\.?\\d{1,2})\\,(?<bv>\\d{1,5}\\.?\\d{1,4})\\,(?<cq>\\d{1,2})\\,(?<mi>\\d*)\\,(?<gs>[012345]{1})\\,(?<gt>\\d{1,5}\\.?\\d?)\\,(?<ac>\\-?\\d{1,3}\\.?\\d{0,3})\\,(?<dc>\\-?\\d{1,4}\\.?\\d{0,3})\\,(?<in1s>[01]{1})\\,(?<in1a>\\d*)\\,(?<in2s>[01])\\,(?<ig>[012])\\#\\#', 'gm')
const str = `\$\$183900057,4002,03/05/2019,22:23:57,33.093139,-97.132556,2213,0.0,0,9,2.3,13.967,27,0,3,0,0.0,0.0,0,0,0,2##`;
// 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