Link to home
Start Free TrialLog in
Avatar of aiwazz
aiwazz

asked on

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

ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial