需要PHP preg_match字符串的正则表达式模式,直到出现“|||”字符

I have PHP variable that contains string like:

http://domain.com/uploads/image1.jpg|||http://domain.com/uploads/image2.jpg|||http://domain.com/uploads/image3.jpg|||...

I need to get first one image url from that string, so it will be string until first "|||" characters. So result i need to get into variable is: http://domain.com/uploads/image1.jpg

Please help me to write correct PHP preg_match regexp pattern for it.

Thank you! Tim

This should work:

'/(.*?)\|\|\|/'

You could also use expode:

$result = explode('|||', $s, 2);
echo $result[0];

Result:

http://domain.com/uploads/image1.jpg

See it working online: ideone

You can use substr:

$pos = strpos($str, "|||");
$firstUrl = substr($myString, 0, $pos ? $pos : strlen($myString));

http://ideone.com/LaudF