cyberhybridhub/lib/utils/spelling_spoken_word.dart
nathanAndrinoid 4459852f83
Some checks failed
Admin portal tests / test (push) Has been cancelled
spelling
2026-06-05 03:22:35 +00:00

25 lines
654 B
Dart

/// Extracts the displayed spelling word from API question text.
///
/// Matches prompts like: Is 'colour' spelled correctly?
String? spellingWordToSpeak(String questionText) {
final RegExp singleQuoted = RegExp(
r"Is\s+'([^']+)'\s+spelled",
caseSensitive: false,
);
final Match? single = singleQuoted.firstMatch(questionText);
if (single != null) {
return single.group(1)?.trim();
}
final RegExp doubleQuoted = RegExp(
r'Is\s+"([^"]+)"\s+spelled',
caseSensitive: false,
);
final Match? double = doubleQuoted.firstMatch(questionText);
if (double != null) {
return double.group(1)?.trim();
}
return null;
}