Files
sign-detector/lib/domain/sign_code.dart
T
2026-09-27 19:12:14 +03:00

11 lines
430 B
Dart

final RegExp _signCodePattern = RegExp(r'\d+(?:\.\d+)+');
/// Pulls a GOST/ПДД number out of a model label.
///
/// `3.27`, `3_27` and `sign-3.27` all become `3.27`.
/// Labels without a dotted number return null: the app must not guess a rule.
String? normalizeSignCode(String rawLabel) {
final unified = rawLabel.trim().replaceAll('_', '.').replaceAll('-', '.');
return _signCodePattern.firstMatch(unified)?.group(0);
}