parent
4522e67c81
commit
19829e10aa
2 changed files with 19 additions and 13 deletions
@ -0,0 +1,16 @@ |
||||
Map<String, String> parseKeyValuePairs(String s, Set<String> targetKeys) { |
||||
final result = <String, String>{}; |
||||
final pairs = s.split(';'); |
||||
for (final pair in pairs) { |
||||
final _index = pair.indexOf(':'); |
||||
if (_index < 0) { |
||||
continue; |
||||
} |
||||
final _key = pair.substring(0, _index).trim(); |
||||
if (targetKeys.contains(_key)) { |
||||
result[_key] = pair.substring(_index + 1).trim(); |
||||
} |
||||
} |
||||
|
||||
return result; |
||||
} |
Loading…
Reference in new issue