feat(frontend): add extractNumber helper

This commit is contained in:
Experiments DB Dev
2026-05-01 07:50:56 -04:00
parent 6a6e6b310a
commit 0b83795665
2 changed files with 42 additions and 0 deletions
+12
View File
@@ -218,3 +218,15 @@ export function runAnalysis(rows, timestampCol, noteCol, classifications) {
consecutiveStats,
};
}
// ── Numeric extraction (for numerical buckets) ────────────────────────────────
/**
* Extract the first signed decimal from a string. Returns null if none found.
* Examples: "L25.5" -> 25.5, "R-12" -> -12, "abc" -> null
*/
export function extractNumber(str) {
if (str == null) return null;
const m = String(str).match(/-?\d+(\.\d+)?/);
return m ? parseFloat(m[0]) : null;
}