How to check if the string contain image extensions

Hi ,
I will receive a string ,i need to check if that string contains image extensions like (.img,.jpg , .jpeg ). set flag if there is image extension in file.

Please help

Hi @tharani.natarajan

You can use System.Text.RegularExpressions.Regex.IsMatch(YourString,“jpg|img|jpeg”).Tostring

cheers

HI @tharani.natarajan

Can you share the input string here

Hi @tharani.natarajan

Checkout this steps

  • Assign a string of Array variable arrStrFormats = {“.img”,“.jpg”,“.jpeg”,“.png”}
  • If activity and pass the condition as
System.Text.RegularExpressions.Regex.IsMatch(StrVar,String.Join("|",arrStrFormats))


  • True-> Your next steps

Regards
Sudharsan

@tharani.natarajan
StrVar = DemoFile.png or Files full path like Folder\DemoFile.png

Regards
Sudharsan

in general we can retrieve the extension like the foolowing (one of more options)
grafik

with a list and some additions we can do:

arrIMGExtensions = {“.img”,”.jpg",“.jpeg”,“.png”}
arrIMGExtensions .Contains(Path.GetExtension(YourString).toLower)

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.