Stop regex splitting a matched url with preg_split

barigain

Junior Member
Joined
Aug 23, 2012
Messages
100
Reaction score
12
Given the following code:


PHP:
$regex = '/(http\:\/\/|https\:\/\/)([a-z0-9-\.\/\?\=\+_]*)/i';$text = preg_split($regex, $note, -1, PREG_SPLIT_DELIM_CAPTURE);
its returning an array such as:


PHP:
array (size=4)  0 => string '...' (length=X)  1 => string 'http s://' (length=8)  2 => string 'duckduckgo.com/?q=how+much+wood+could+a+wood-chuck+chuck+if+a+wood-chuck+could+chuck+wood' (length=89)  3 => string '...' (length=X)

I would prefer it if the returned array had size=3, with one single URL. Is this possible?

Thank you in advance!
 
I've solved this problem by myself. Thank you
 
Back
Top