There is a lot of band that you donβt need ... well, if there is something you havenβt mentioned, this regular expression will do the same:
/.*\.(jpg|png|bmp)$/i
This is in the regex notation, in C #, which will be:
String regex=new RegEx(@".*\.(jpg|png|bmp)$",RegexOptions.IgnoreCase);
If you need to programmatically translate between the two, you started on the right track - separated by a semicolon, grouped your extensions into a set (without the previous dot). If your wildcard patterns can be more complex (wildcard extensions, matches with multiple wildcards), you may need a little more work;)
Edit: (for your update)
If wild cards can be more complex, then you are almost there. In my code above there is an optimization that draws a point (for extension) that needs to be returned so you can:
/.*(myfile\.jpg|\.png|\.bmp)$/i
Mostly '*' β '. * ','. ' β '\.' (slips away), rest turns into a set. Basically, he says that something ends (the dollar sign is tied to the end) in myfile.jpg , .png or .bmp .
source share