When using extractregex() inside a {run} command in Text Blaze, if the target value is missing in the input text, the entire script stops executing at that point. This means that any {run} commands placed after a missing value do not run.
To work around this, we have to write each {run} command separately, which is inconvenient and makes the script longer and harder to maintain.
Expected Behavior
If extractregex() does not find a match, it should return an empty string ("") or null, and execution should continue with the next {run} command instead of stopping entirely.
Current Workaround (Inefficient)
To avoid stopping execution, each {run} command must be written separately:
{run: wbc=extractregex({=chart},"White Blood Cell Count\s*[HL]?\s*([\d.]+)\s*/MCL")}
{run: rbc=extractregex({=chart},"Red Blood Cell Count\s*[HL]?\s*([\d.]+)\s*X10000/MCL")}
{run: hgb=extractregex({=chart},"Hemoglobin\s*[HL]?\s*([\d.]+)\s*G/DL")}
{run: hct=extractregex({=chart},"Hematocrit\s*[HL]?\s*([\d.]+)\s*%")}
{run: ldl=extractregex({=chart},"LDL Cholesterol\s*[HL]?\s*([\d.]+)\s*MG/DL")}
{run: hdl=extractregex({=chart},"HDL Cholesterol\s*[HL]?\s*([\d.]+)\s*MG/DL")}
This approach works, but it is cumbersome when handling many fields.
Problematic Example (Fails)
If we attempt to combine multiple extractions inside a single {run}, execution stops at the first missing value:
{run:
wbc=extractregex({=chart},"White Blood Cell Count\s*[HL]?\s*([\d.]+)\s*/MCL")
rbc=extractregex({=chart},"Red Blood Cell Count\s*[HL]?\s*([\d.]+)\s*X10000/MCL")
hgb=extractregex({=chart},"Hemoglobin\s*[HL]?\s*([\d.]+)\s*G/DL")
hct=extractregex({=chart},"Hematocrit\s*[HL]?\s*([\d.]+)\s*%")
ldl=extractregex({=chart},"LDL Cholesterol\s*[HL]?\s*([\d.]+)\s*MG/DL")
hdl=extractregex({=chart},"HDL Cholesterol\s*[HL]?\s*([\d.]+)\s*MG/DL")
}
If rbc is missing from {=chart}, the execution stops, and hgb, hct, ldl, and hdl are never extracted.
Proposed Solution
Modify extractregex() so that when no match is found, it returns an empty string ("") instead of stopping execution.
Allow a default value option, e.g., extractregex({=chart},"LDL Cholesterol\s*([\d.]+)\s*MG/DL", ""), so missing values do not cause execution failure.
Ensure {run} continues executing even if a value is missing.
This issue makes it difficult to handle structured text extraction efficiently. A built-in solution to allow {run} to continue execution even when extractregex() fails to match would significantly improve usability.
Would appreciate any insights or potential fixes from the Text Blaze team!