$string = "c4414b8e90510db12 GET /emailtrack/blank.gif?source=mailchimp&guid=12345&campaign=myCampaign HTTP/1.1"
preg_match_all('/("GET.*?"+)/is',$string,$match);
Result:
Array (
[0] => Array (
[0] => "GET /emailtrack/blank.gif?source=mailchimp&guid=12345&campaign=myCampaign HTTP/1.1"
)
[1] => Array (
[0] => "GET /emailtrack/blank.gif?source=mailchimp&guid=12345&campaign=myCampaign HTTP/1.1"
)
)
Parsing the string through preg_match_all just to fetch the GET String but it returns 2 results of GET string, I only need one result in the array
Thanks for the earlier answer it worked for me.
$string = "source=xxxx&campaign=asdas&guid=121"
Is there anyways you can help me with telling me a regex for extracting just the source=xxxxx from the string above
I tried this
preg_match_all('/source.*?\s/', $string, $match);
But it gives me the entire string ,I want to separate the strings source, campaign & guid
The first entry of the result is always the full match. You also have additional parentheses around the entire pattern, which is becoming the first “subpattern”.
Solution: Remove the parentheses.