I know that I saw this a lot, but I need something more than the norm. Unfortunately, when I look for it somewhere, it digs into messages about a simple html tag link connection. I want the PHP function to extract "http: //" and "https: //" from the link, as well as something after it. * So basically what I'm looking for is to turn A into B.
A: http:
If that helps, here is my current regular PHP replace function.
ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"\\0\" class=\"bwl\" target=\"_new\">\\0</a>", htmlspecialchars($body, ENT_QUOTES)));
Perhaps it would also be useful to say that I absolutely do not understand in regular expressions. Thanks!
EDIT: When I entered a comment like this blahblah https://www.facebook.com/?sk=ff&ap=1 blah , I get html like this <a class="bwl" href="blahblah https://www.facebook.com/?sk=ff&ap=1 blah">www.facebook.com</a> , which doesn't work at all because it takes the text around the link with it. It works great if only someone comments on the link. This is when I changed the function to this
preg_replace("#^(.*)//(.*)/(.*)$#",'<a class="bwl" href="\0">\2</a>', htmlspecialchars($body, ENT_QUOTES));
source share