Skip to content

Instantly share code, notes, and snippets.

@bartekpacia
Last active September 20, 2024 18:25
Show Gist options
  • Save bartekpacia/3e3acc7072aeff2e4479f2884a79075a to your computer and use it in GitHub Desktop.
Save bartekpacia/3e3acc7072aeff2e4479f2884a79075a to your computer and use it in GitHub Desktop.
final _declarativeKotlinPluginPatterns = <RegExp>[
RegExp('^\\s*id\\s*\\(?\\s*[\'"]kotlin-android[\'"]\\s*\\)?\\s*\$'),
RegExp(
'^\\s*id\\s*\\(?\\s*[\'"]org.jetbrains.kotlin.android[\'"]\\s*\\)?\\s*\$'),
];
final lines = <String>[
'id "kotlin-android"',
'id("kotlin-android")',
'id ( "kotlin-android" ) ',
'id "org.jetbrains.kotlin-android"',
'id("org.jetbrains.kotlin-android")',
'id ( "org.jetbrains.kotlin-android" )'
];
void main() {
var linesMatched = 0;
for (final line in lines) {
print('\n---line: $line---\n');
_declarativeKotlinPluginPatterns.where((pattern) {
final hasMatch = pattern.firstMatch(line) != null;
if (hasMatch) {
linesMatched++;
print('hasMatch! pattern: $pattern');
}
return hasMatch;
}).forEach((_) {});
print('Lines matches: $linesMatched/${lines.length}');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment