-1

I have a link (string) which contains a filename. I need to extract the format of the filename but I am unfortunately not able to do that. An example link is given below

www.xyz.com/private/videos/89FDJKDKFgrFTD-MUyKE9Sn/source?file-name=SampleAudio_0.4mb.mp3&token=exp=1591202847~acl=/private/videos/8OJFREFJOIJFREJ-MUyKE9Sn/source*~hmac=aef161514cdfodsjfodsjorjef081b4c849b8c29c6a37339803866badfd4a16

I have tried multiple ways like to look for .(dot) until & but since I am new to this I couldn't make this work. I got the filename through name=([^&]*) but could not get the extension. Is there a way to do this?

Ali Turab Abbasi
  • 1,103
  • 8
  • 22

1 Answers1

1

You can use this regex:

(?:file-name=.*)(\..+)(?:&)

Also see working example: https://regex101.com/r/CJDXLW/2

Doruk Eren Aktaş
  • 2,121
  • 8
  • 23