I don't remember exactly what happened, it's just in my notes that "it didn't work".
Sometimes we would then read you the riot act for simply saying “It doesn’t work” without further explanation ;) but here I am fully prepared to believe it, because lookbehinds have to be of fixed length. I'm not sure if this is universally true of all RegEx engines, but it applies to all that I've used. (We won't talk about javascript, which doesn't support lookbehinds at all. Ugh.)
what does the ? in (https?://) do?
It makes the s optional. It's what you would have said in the lookbehind if you were allowed to do so, darn it. You may have been led astray by the ?: sequence, since (?:blahblah) would have special meaning, but in all other environments a colon is just a colon--here, the literal colon in the full URL.
So let's reconstruct. In the beginning you had the simple matter of meeting
http:/
/www.blahblah in posts, so you dutifully converted
(https?://\S+)
into
<a href = "$1" target = "_blank">$1</a>
And then you realized that some of those posts happened to have sentence-final punctuation immediately afterward, leading to bad links, so it became
(https?://\S+\w)
>>
<a href = "$1" target = "_blank">$1</a>
And then it turned out some people weren't saying the http:// part, which is where the lookbehind comes in, because thanks to that pesky SSL you can no longer postulate http, so now for the others you have to go through a second loop of
(?<!://)(www\.\S+\w)
>>
<a href = "http://$1" target = "_blank">$1</a>
(and if it's really an https site it will just jolly well have to redirect, because you can't be expected to do
everything) ... except for the sitenames that don't start in www, which is another loop unless you decide, reasonably enough, that there's a limit to auto-linking and you really can't be bothered ...
And THEN you remembered about links to images on your site, meaning that all of the above have to be
preceded by
(https?://)?((?:www\.)?example\.com/)([\w-/]+\.(jpg|gif|png))
>>
<img src = /"$3">
which would then be followed by code for ordinary links to pages on your own site, again stripped down to leading / and .... Oh, lord, we haven't even got through all your patches yet, have we. Which ones did I overlook?
We begin to understand why it's so tempting to use prefab forum/discussion software.