Separate a receipt's fields on any whitespace, not only a space

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Csos3Vfm66NrAywQUe3e4V
This commit is contained in:
2026-09-01 21:37:19 +02:00
parent a91c55cc64
commit 0fd6da1542
3 changed files with 15 additions and 12 deletions
+5 -4
View File
@@ -56,17 +56,18 @@ export type Dlr = {
statusMsg: MessageState;
};
const field = (name: string) => new RegExp(`\\b${name}:([^ ]*)`, 'i');
const field = (name: string) => new RegExp(`\\b${name}:(\\S*)`, 'i');
const patterns = {
dlvrd: field('dlvrd'),
doneDate: /\bdone date:([^ ]*)/i,
doneDate: field('done date'),
err: field('err'),
id: field('id'),
stat: field('stat'),
sub: field('sub'),
submitDate: /\bsubmit date:([^ ]*)/i,
text: /\btext:(.*)$/i,
submitDate: field('submit date'),
// The last field, and the only one that may hold a space: it carries the message's own start.
text: /\btext:([^\r\n]*)/i,
};
function toNumber(value: string | undefined): number | undefined {