[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 278
  • Last Modified:

Adding a word to url regex string for a match

Yes, another regex noob asking for regex help... ;) Can the regex in the code block below be modified so that it only allows matches that contain the word gallery in the url before the filename/extension? The url will always look like http://www.***.***/***/gallery/*/filename.*. The wildcard after the gallery directory is a folder numbering system.

Possible? Thanks!


$pattern = '/\b(http:\/\/[-A-Z0-9+ \t\(\)&@#\/%?=~_|!:,.;]*[-A-Z0-9+ \t\(\)&@#\/%=~_|]\.(?:jpg|jpeg|png|gif|bmp))/si';
   preg_match_all($pattern, $row['body'], $matches);

Open in new window

0
aiwazz
Asked:
aiwazz
1 Solution
 
ozoCommented:
$pattern = '/\b(http:\/\/[-A-Z0-9+ \t\(\)&@#\/%?=~_|!:,.;]*gallery[-A-Z0-9+ \t\(\)&@#\/%=~_|]*\.(?:jpg|jpeg|png|gif|bmp))/si';
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now