llmParseNodeVersion function

({int major, String version})? llmParseNodeVersion(
  1. String answer
)

v22.22.3, 22.22.3 or a line starting with either → the normalised version and its major; null for anything else.

Implementation

({String version, int major})? llmParseNodeVersion(String answer) {
  final match = RegExp(r'^v?(\d+)\.(\d+)\.(\d+)').firstMatch(answer.trim());
  if (match == null) return null;
  return (
    version: 'v${match.group(1)}.${match.group(2)}.${match.group(3)}',
    major: int.parse(match.group(1)!),
  );
}