25 lines
654 B
Dart
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;
|
|
}
|