Regex Problem: name capture, preg_match
Given the following strings:
application/pdf; name=a.pdf
application/pdf; name="b.pdf"
application/pdf; name="c.pdf
application/pdf; name=d.pdf"
I need the following values in a capture named "filename":
a.pdf
b.pdf
c.pdf
d.pdf
The following regex works for a.pdf
, but fails for the rest due to the dou开发者_C百科ble quotes:
name=(?<filename>.*)
Any suggestions how I can get the rest? Thanks.
Try this one:
/name="?(?<filename>[^"]*)"?/
精彩评论