开发者

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>[^"]*)"?/
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜