I need to use PHP's preg_match() and Regex to detect the following conditions:
If a URL path is one of the following:
products/new itemsnew items/productsnew items/products/brand name
Do something...
I can't seem to figure out how to check if the a string exists before or after the word products. The closest I can get is:
if (preg_match("([a-zA-Z0-9_ ]+)\/products\/([a-zA-Z0-9_ ]+)", $url_path)) {
// Do something
Would anyone know a way to check if the first part of the string exists within the one regex line?

this?([\w_ ]+)\/products|products\/([\w_ ]+)'~([^\/]*)(?:^|\/)products(?:\/|$)([^\/]*)~'productstoo