从仅包含URL字符串中的特定单词的文本中获取图像URL

I use preg_match_all to get all images URLs from the text string:

preg_match_all('!http://[^?#]+\.(?:jpe?g|png|gif)!Ui', $text , $matches);
  • Unfortunately, this time I need to get only images that contains '/bigimage/' inside the initial string.

  • i.e. $matches array should have only contains image elements like:

  http://x/x/bigimage/x/x.jpg
  • How could I modify source command to get desired result?

try

(http://(?:\w+/)*bigimage(?:/\w+)*((/\w).(?:jpe?g|png|gif)))

for visualization https://www.debuggex.com/r/22db9byd3cTlIX6f

Change the brackets () or capturing groups according to your need