extractDefaultValue function

String? extractDefaultValue(
  1. String question
)

Parses a (empty = X): or (empty keeps 'X'): hint from question, returning X so the TUI prompt can show it as the default value, or null when no default hint is present.

Implementation

String? extractDefaultValue(String question) {
  final match = RegExp(r'\(empty\s*=\s*(.+?)\)').firstMatch(question);
  if (match != null) return match.group(1)!.trim();
  final keeps = RegExp(r"\(empty\s*keeps\s*'(.+?)'\)").firstMatch(question);
  if (keeps != null) return keeps.group(1)!.trim();
  return null;
}