regular expression help - proprtly pase full url from string |
[eluser]new_igniter[/eluser]
Hello, Can someone share a regex that properly handles grabbing a http link from a string of text? What I have below works, but not in all circumstances, i.e. link has ),>,:, etc on the end. So I would love to know people's experiences with this and how they solved it. Thanks! Code: $regex = '/(http:\/\/[^&"\'\s]+)/i'; for CI search: regex grab url from text, grab url from string,
[eluser]Pascal Kriete[/eluser]
Take a look at the auto_link function in the URL Helper, to see how CI handles it (system/helpers/url_helper.php :: line 377). You might also be interested in the work Sophistry has done here. Hope that helps.
|
Welcome Guest, Not a member yet? Register Sign In |