Q:

Regex match 2 conditions

Currently, I'm using this 2 regex on this WordPress plugin called redirection to filter out certain URL from being logged.
(food) to match anything containing food word anywhere in the URL.
((.js)|(.css))$ to match any .js or .css at the end of URL
How do I combine this 2 regex into 1 with AND so I can get the expected output below?
EXPECTED OUTPUT:
https://example.com/food/test/apple.css - match
https://example.com/food/fruit/pineapple.css - match
https://example.com/food/fruit/apple.php - NOT match
https://example.com/food/new/strawberry.js - match

I've been trying this for hours but still can't make it work. I'm not good with Regex. How do I make it work with (food) AND ((.js)|(.css))$
I tried this combination below but failed. Please help me. Thanks in advance.
(food)&((.js)|(.css))$ 
(food)+((.js)|(.css))$ 
(food)/((.js)|(.css))$ 

A:

You may use
'~.*food.*\.(?:js|css)$~'

See the regex demo.
If /food/ must be there use
'~.*/food/.*\.(?:js|css)$~'

If you are just testing for a match, remove the first .*.
Details

.* - 0+ chars, as many as possible
food - a literal substring
.* - 0+ chars, as many as possible
\.(?:js|css) - . followed with js or css
$ - end of string

