Last active
September 20, 2024 18:25
-
-
Save bartekpacia/3e3acc7072aeff2e4479f2884a79075a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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