Created
October 25, 2022 18:15
-
-
Save vadimtsushko/0fc982c6f709d4b4c733e25c9195800d 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
void main() { | |
var barcode = '0023,023,45,567'; | |
var arrayBarcode = barcode.split(','); | |
var arrayZeroLeading = arrayBarcode.where((e) => e.startsWith('0')); | |
var arrayNonZeroLeading = arrayZeroLeading.map((e) => e.replaceFirst(RegExp('^0+'),'')).toList(); | |
var arrayOutput = arrayBarcode..addAll(arrayNonZeroLeading); | |
var barcodeOut = arrayOutput.toSet().join(','); | |
print(barcodeOut); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment