$re = '/^\[[^]]+\]: builds\/app\/(.+?)\.(ipa|apk)$/m';
$str = '[14:54:35]: [32m-------------------------------------------------[0m
[14:54:35]: [32m--- Step: Switch to android upload_to_s3 lane ---[0m
[14:54:35]: [32m-------------------------------------------------[0m
[14:54:35]: Cruising over to lane \'android upload_to_s3\' 🚖
[14:54:37]: builds/app/oneoff/android/22.26.2_15_225877//app-oneoff-release.apk
[14:54:37]: Cruising back to lane \'android build_oneoff\' 🚘';
preg_match($re, $str, $matches, PREG_OFFSET_CAPTURE, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php