PHP正则表达式匹配第一次出现?

http://someurlhere.com|http://sometexturl.com|sometexthere

i want to extract only the first url which is before the | , http://someurlhere.com

i have written regular expression

\bhttp(.*)\|\b

but its capture all the occurences of |

Thanx help is appreciated

No need for regex. I see you tagged it PHP.

$boom = explode('|', 'http://someurlhere.com|sometexturl.com|sometexthere');
$url = $boom[0];
echo $url;

Output:

http://someurlhere.com

http://codepad.org/xnW0FTfA

Make the .* ungreedy : .*?

\bhttp(.*?)\|\b

If you want to match only after the first | do:

\|http://(.*?)\|

with this, the url is in $1

This isn't a exact answer, but I will point you towards information that help you solve this issue!

Regex: matching up to the first occurrence of a character