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
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!
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.