aamva-parser
Version:
Plugin to parse AAMVA Drivers License Data from the PDF417 barcode
18 lines (15 loc) • 446 B
text/typescript
export class Regex {
firstMatch(pattern: string, data: string): string | null {
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;
}
}
}