Issue
I want to know how can i compare file extension
void main() {
List<String> image = ["sdasd/dsd.png","sdafd/ddd.jpeg","sdsdd/dgd.gif","sdasd/dhd.png","sdasd/dhd.txt",];
final RegExp regExp =
RegExp(".(gif|jpe?g|tiff?|png|webp|bmp)", caseSensitive: true);
for (var img in image) {
print(img.contains(regExp));
}
}
output:- true true true true false
Problem if i put ".pngk" it show me "true",
need help
Solution
Your regex is looking for matches in the entire string, not at the end.
Add $
to end:
".(gif|jpe?g|tiff?|png|webp|bmp)\$"
$
matches position just after the last character of the string.
Answered By - Ivan Braiko
Answer Checked By - Marie Seifert (JavaFixing Admin)