aamva-parser
Version:
Plugin to parse AAMVA Drivers License Data from the PDF417 barcode
17 lines (16 loc) • 453 B
JavaScript
export class Regex {
firstMatch(pattern, data) {
try {
const regex = new RegExp(pattern, 'i');
const matches = regex.exec(data);
if (!matches || matches.length < 2) {
return null;
}
const matchedGroup = matches[1].trim();
return matchedGroup.length > 0 ? matchedGroup : null;
}
catch (error) {
return null;
}
}
}