I’m trying to match a regular expression in order to extract a value of a substring.
I’ve read on regular expression syntax but it seems I still can’t get it right.
I have the following coming from http response:
Content-Disposition: attachment; filename=Subtitle.197747.zip; type=s
Content-Disposition: attachment; filename="file one.txt" type=s
Content-Disposition: attachment; filename="file one.txt"; type=s
Content-Disposition: attachment; filename=Subtitle.197747.zip type=s
I’m trying to extract the value of filename without the double quotes if specified.
Came up with something like:
`.*filename="?(?<filename>[^;"]*)\s?.*`
But this doesn’t seem to do the trick, would appreciate some guidance.
Thanks everyone for your answers, I read them all and went with:
filename="?(?<filename>[^;"]+)[\s;"]
Though I’m not sure how to get it to get it to compile correctly (either \s or ” giving me troubles).
Try this