feat: AV/BV号直接跳转
This commit is contained in:
@ -46,4 +46,28 @@ class IdUtils {
|
||||
}
|
||||
return (r - ADD) ^ XOR;
|
||||
}
|
||||
|
||||
// 匹配
|
||||
static Map matchAvorBv({String? input}) {
|
||||
Map result = {};
|
||||
if (input == null || input == '') {
|
||||
return result;
|
||||
}
|
||||
RegExp bvRegex = RegExp(r'BV[0-9A-Za-z]{10}', caseSensitive: false);
|
||||
RegExp avRegex = RegExp(r'AV\d+', caseSensitive: false);
|
||||
|
||||
Iterable<Match> bvMatches = bvRegex.allMatches(input);
|
||||
Iterable<Match> avMatches = avRegex.allMatches(input);
|
||||
|
||||
List<String> bvs = bvMatches.map((match) => match.group(0)!).toList();
|
||||
List<String> avs = avMatches.map((match) => match.group(0)!).toList();
|
||||
|
||||
if (bvs.isNotEmpty) {
|
||||
result['BV'] = bvs[0].substring(0, 2).toUpperCase() + bvs[0].substring(2);
|
||||
}
|
||||
if (avs.isNotEmpty) {
|
||||
result['AV'] = avs[0].substring(2);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user