Regex is not really my thing. But i have this in my php file and have found it wont work if the string passed has any spaces. Can someone offer an amendment please.
regex:
preg_match('/^(\S+)\/\d/', $_SERVER['HTTP_USER_AGENT'], $matches);
$product_name = $matches[1];
the string will always be in the form of:
1productname/1.0.9 Sparkle/2
everything after the forward slash remains constant
before the forward slash can change, and this is the portion i am looking for.
i have found if the first portion contains spaces like:
1 product name/1.0.9 Sparkle/2
this will break.
Try this:
/^(.+?)\/\d/If you weren’t trying to match the value after, try this:
/^(.+?)\//