I wanted to perform a regex in php. From the $str variable I want to select out common_name = Bangladesh . I wore my regex. The regex is not finding any match here. How can I fix this?
$str = "| conventional_long_name = People's Republic of Bangladesh | common_name = Bangladesh | image_flag = Flag of Bangladesh.svg";
$pat = "/(?=\common_name\s=).*?(?=\s\|)/";
if(preg_match($pat, $str, $matches)){
echo "Matches found";
echo $matches[0];
} else {
echo "No match found";
}
the result shows
No match found