Need PHP pregmach Regexp pattern for string until “|||” characters appears

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

Answers


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


Need Your Help

platform_device_register and usb ehci driver

linux linux-kernel linux-device-driver

I'm trying to understand how linux initializes USB EHCI controller on my cambria (ARM) board.

Paypal Recurring Payment through ACH in Php

php paypal payment recurring

I have researched through the Paypal website regarding Recurring ACH payment in PHP but could not find any satisfying solution. Paypal has mentioned SDKS for C# & Java for Recurring ACH, but no...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.