RegEX从序列化PHP数组中提取图像名称

时间:2022-10-16 12:34:27

I need to capture an image name from a serialized PHP array. I would love to de-serialize it in PHP first but in this case I can not do that because of the current setup, so it must be done without de-serializing it. The part I need to capture is the thumbnail image Capture-49-150x150.png

我需要从序列化的PHP数组中捕获图像名称。我希望首先在PHP中对它进行反序列化,但在这种情况下,由于当前的设置,我不能这样做,因此必须在不对其进行反序列化的情况下完成。我需要捕捉的部分是缩略图Capture-49-150x150.png

Here is what I have so far using regex101 I can't seem to get it narrowed down to just the file name. Hoping someone here can help me out to finalize it.

这是我到目前为止使用的regex101我似乎无法将其缩小到只是文件名。希望有人在这里可以帮助我完成它。

This is the entire contents of the serialized array

这是序列化数组的全部内容

a:5:{s:5:"width";i:472;s:6:"height";i:496;s:4:"file";s:22:"2016/10/Capture-49.png";s:5:"sizes";a:2:{s:9:"thumbnail";a:4:{s:4:"file";s:22:"Capture-49-150x150.png";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-type";s:9:"image/png";}s:6:"medium";a:4:{s:4:"file";s:22:"Capture-49-285x300.png";s:5:"width";i:285;s:6:"height";i:300;s:9:"mime-type";s:9:"image/png";}}s:10:"image_meta";a:12:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";s:11:"orientation";s:1:"0";s:8:"keywords";a:0:{}}}

1 个解决方案

#1


0  

\B"thumbnail"\B.+?file.*?\B"\K.+?(?:png|jpe?g). – Wiktor Stribiżew

\ B“thumbnail”\ B。+?file。*?\ B“\ K。+?(?:png | jpe?g)。 - WiktorStribiżew

#1


0  

\B"thumbnail"\B.+?file.*?\B"\K.+?(?:png|jpe?g). – Wiktor Stribiżew

\ B“thumbnail”\ B。+?file。*?\ B“\ K。+?(?:png | jpe?g)。 - WiktorStribiżew